Making perl script running under bash cygwin
Gerrit P. Haase
freeweb@nyckelpiga.de
Thu Dec 6 10:42:00 GMT 2001
Hallo Jorge,
2001-12-06 19:22:29, du schriebst:
> Hi, I have this :
> system("perl -i.orig -pe 's!/home/ftp!/!g' c:/cygwin/etc/passwd") or die;
> And it dies always althought it works if I run it by Hand in the cygwin bash.
> Why?
Cannot say the exact raeson, but i left out the 'or die' and it works.
#!/usr/bin/perl
$args = "perl -i.orig -pe \'s!/home/ftp!/!g\' /etc/passwd";
system($args);
Maybe some native english speaker has a better understanding of this
part of perlrun.pod:
-p causes Perl to assume the following loop around your
program, which makes it iterate over filename arguÂ
ments somewhat like sed:
LINE:
while (<>) {
... # your program goes here
} continue {
print or die "-p destination: $!\n";
}
If a file named by an argument cannot be opened for
some reason, Perl warns you about it, and moves on to
the next file. Note that the lines are printed autoÂ
matically. An error occurring during printing is
treated as fatal. To suppress printing use the -n
switch. A -p overrides a -n switch.
"BEGIN" and "END" blocks may be used to capture conÂ
trol before or after the implicit loop, just as in
awk.
Gerrit
--
convey Information Systems GmbH http://www.convey.de/
VitalisstraÃe 326-328
Gerrit P. Haase D-50933 Köln
gerrit.haase@convey.de Fon: ++49 221 6903922
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list