Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2017-06-26 05:41 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (572 votes). Check out past polls.