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
ay, October 06, 2003 11:20 AM To: [EMAIL PROTECTED] Subject: Add text to beginning every line Hi Hope someone can help with this. I used to be able to do it, but now have forgotten. I want to prepend some text to every line in a file. The program below: #!/usr/bin/perl # prepend.pl - adds line nu

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

Add text to beginning every line

2003-10-07 Thread Chris Charley
Hi Hope someone can help with this. I used to be able to do it, but now have forgotten. I want to prepend some text to every line in a file. The program below: #!/usr/bin/perl # prepend.pl - adds line number to beginning of every line in a file use strict; use warnings; while (<>) { s/^/Li