Re: reading commandline parameters and <>

2004-06-07 Thread Chris Charley
- Original Message - From: "Chris Charley" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: <[EMAIL PROTECTED]> Sent: Monday, June 07, 2004 2:07 PM Subject: Re: reading commandline parameters and <> > > I am sorry I did not give the real situation

Re: reading commandline parameters and <>

2004-06-07 Thread Chris Charley
> I am sorry I did not give the real situation before, I want to execute > this on command line like > > perl -pe 's/$ARGV[1]/$ARGV[2]/' filename OLDSTR NEWSTR > > Is this possible ? > > Thanks > Ram Why not perl -pe 's/OLDSTR/NEWSTR/' filename -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: reading commandline parameters and <>

2004-06-07 Thread Jeff 'japhy' Pinyan
On Jun 7, Ramprasad A Padmanabhan said: >open(IN,$ARGV[0]) || die $!; >while(){ > 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 here Yes, if you first remove $AR

reading commandline parameters and <>

2004-06-07 Thread Ramprasad A Padmanabhan
I am running a perl program that reads a file name from commandline substitutes one string with another displays the output #!/usr/bin/perl open(IN,$ARGV[0]) || die $!; while(){ s/$ARGV[1]/$ARGV[2]/; print; } exit 0; __END__ # I run this using command # perl myscript.pl THEFILE OLDSTR NEWS