Re: Add text to beginning every line

2003-10-07 Thread Tore Aursand
On Mon, 06 Oct 2003 14:20:05 -0400, Chris Charley wrote: > Then, on the command line I type: perl prepend.pl somefile.txt, but > somefile.txt does not have the changes(Line: ). Try writing 'perl prepend.pl somefile.txt > newfile.txt' instead. -- Tore Aursand <[EMAIL PROTECTED]> -- To unsubsc

RE: Add text to beginning every line

2003-10-07 Thread Thomas Bätzler
Hi, Chris Charley <[EMAIL PROTECTED]> wrote: > Should be (works correctly): > > while (<>) { >s/^/Line: $. /; >print; > } > > Then the command could be:perl prepend.pl somefile.txt > > somefile.new > which would correctly print to the 'new' file the > somefile.txt file wi

Re: Add text to beginning every line

2003-10-07 Thread Sudarshan Raghavan
Chris Charley wrote: > "Chris Charley" <[EMAIL PROTECTED]> wrote in message news:... > [snip] > > while (<>) { > > s/^/Line: $. /; > > } > > Should be (works correctly): > > while (<>) { >s/^/Line: $. /; You don't need a regular expression to do this. This should suffice $_ = "Line

RE: Add text to beginning every line

2003-10-07 Thread Tim Johnson
You're reading in the file, but not changing it. You're only changing it in memory. Check out the responses to the other post called "make changes to a file, then reading in those changes" -Original Message- From: Chris Charley [mailto:[EMAIL PROTECTED] Sent: Monday, October 06, 2003 1

Re: Add text to beginning every line

2003-10-07 Thread Chris Charley
"Chris Charley" <[EMAIL PROTECTED]> wrote in message news:... [snip] > while (<>) { > s/^/Line: $. /; > } Should be (works correctly): while (<>) { s/^/Line: $. /; print; } Then the command could be:perl prepend.pl somefile.txt > somefile.new which would correctly prin