Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: providing filenames dynamically

by balakrishnan (Monk)
on Feb 24, 2009 at 06:01 UTC ( #745907=note: print w/replies, xml ) Need Help??

in reply to providing filenames dynamically

You have to change your code like,
print "file1 ="; $file1=<stdin>; print "file2 =" ; $file2=<stdin>; @ARGV = ("$file1", "$file2") ; chomp($remove = <stdin>); chomp($replace = <stdin>); while(defined($line=<>)){ $line =~ s/$remove/$replace/g; print "$line"; }
When your code seems not giving the expected result, you can use the perl debugger to find out issue.
I debugged the code, after made the change from {} to ()
main::(./ print "file1 ="; DB<1> n main::(./ $file1=<stdin>; DB<1> n file1 =file1 main::(./ print "file2 =" ; DB<1> n main::(./ $file2=<stdin>; DB<1> n file2 =file2 main::(./ @ARGV = ("$file1", "$file2") ; DB<1> n main::(./ chomp($remove = <stdin>); DB<1> p @ARGV file1 file2

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://745907]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2016-10-26 09:12 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (338 votes). Check out past polls.