Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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::(./dynamic_file.pl:22): print "file1 ="; DB<1> n main::(./dynamic_file.pl:23): $file1=<stdin>; DB<1> n file1 =file1 main::(./dynamic_file.pl:24): print "file2 =" ; DB<1> n main::(./dynamic_file.pl:25): $file2=<stdin>; DB<1> n file2 =file2 main::(./dynamic_file.pl:26): @ARGV = ("$file1", "$file2") ; DB<1> n main::(./dynamic_file.pl:27): chomp($remove = <stdin>); DB<1> p @ARGV file1 file2


Comment on Re: providing filenames dynamically
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2014-09-22 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls