Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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

Comment on Re: providing filenames dynamically
Select or Download Code

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 surveying the Monastery: (2)
As of 2015-10-04 13:10 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (102 votes), past polls