On Thursday 01 November 2007 11:25, boxingcat wrote: > / Sorry if it is a repost. didn't see the first one in the group. > > > I would like to replace string 1 with string 2 in file3.dat, here is > what I did: > > #!/usr/bin/perl
use warnings; use strict; > @inputfile= ("string1"); # need to have an arrary later > @outputfile=("string2"); > @attfile=("file3.dat"); > > $mytempfile=$inputfile[0]; > $youtempfile=$outputfile[0]; > $hisfile=$attfile[0]; > > perl -pi -e 's/$mytempfile/$youtempfile/' $hisfile; You are trying to run an external program in perl (this is not a shell script.) perldoc -f system perldoc -f qx perldoc -f open However you can do what you want directly in perl: { local ( $^I, @ARGV ) = ( '', $attfile[ 0 ] ); while ( <> ) { s/$inputfile[0]/$outputfile[0]/; print; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/