T
tweetiebirds
Hi,
This may be a dumb question and excuse me if it is:
In a Perl program, let's say I need to replace a string in a text file
with another.
What is best?
1. Open the file , get a file handle and then
open(HANDLE, "flname");
while (<HANDLE>) {
if /pattern {
s/pattern/newpattern/g;
}
close(HANDLE)
}
or
2.
system ("perl -pi -e 's/pattern/newpattern/g' flname");
Is it good to call PERL from PERL?
or
3.
$repl = `perl -pi -e 's/pattern/newpattern/g' flname`;
thanks !
This may be a dumb question and excuse me if it is:
In a Perl program, let's say I need to replace a string in a text file
with another.
What is best?
1. Open the file , get a file handle and then
open(HANDLE, "flname");
while (<HANDLE>) {
if /pattern {
s/pattern/newpattern/g;
}
close(HANDLE)
}
or
2.
system ("perl -pi -e 's/pattern/newpattern/g' flname");
Is it good to call PERL from PERL?
or
3.
$repl = `perl -pi -e 's/pattern/newpattern/g' flname`;
thanks !