good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Append to beginning of line (multi line file)by FireBird34 (Pilgrim) |
on Jan 23, 2003 at 20:12 UTC ( [id://229412]=perlquestion: print w/replies, xml ) | Need Help?? |
FireBird34 has asked for the wisdom of the Perl Monks concerning the following question:
Just as a fun thing to do, I decided to make a command line program that will number each line in a file (don't ask why -- I just decided to do it ;)). So given the contents:
alpha bravo charlie delta The program would make that: 1. alpha 2. bravo 3. charlie 4. delta The way I have it right now, the contents will turn into: alpha bravo charlie delta1. 2. 3. 4. Can't seem to make the numbers append to the start of each file *lol*. So here is my code: Any suggestions on either making this code cleaner and/or making it work properly? (keep in mind that this was a trial and error thing on my part -- reading the lines in the file -- so I am unsure if there is a more effective way) Also, I had to re-type this from the editor, as it isn't coppying properly -- if you see a typo, that is why.
Back to
Seekers of Perl Wisdom
|
|