On Jun 7, Ramprasad A Padmanabhan said: >open(IN,$ARGV[0]) || die $!; >while(<IN>){ > s/$ARGV[1]/$ARGV[2]/; > print; >} >exit 0;
Do you come from C? It's hardly ever necessary to exit(0) at the end of a Perl program. >Can I use <> instead on open file and then <IN> here Yes, if you first remove $ARGV[1] and $ARGV[2]; here are some ways: my ($from, $to) = splice @ARGV, 1, 2; my ($to, $from) = (pop @ARGV, pop @ARGV); # <-- backwards! Then you can do: while (<>) { s/$from/$to/; print } -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.] <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>