FAQ

On Mar 7, 2014, at 1:58 PM, sb@missionstclare.com wrote:

I have some text files from which I would like to remove the first line, but only if it's blank. Any hints? I tried a few things, but the results haven't quite been satisfactory.
You should be able to do that in just a few lines of Perl:

1. Open the existing file for reading.
2. Open a new file for writing.
3. Read the first line in the input file.
4. If the first line is not blank, write it to the output file.
5. Read the remaining lines from the input file and write to the output file.
6. Close both files
7. Optionally: rename both files to give the new file the same name as the old file.

If you don't understand any of the steps, just ask. If you have trouble, post your program here, and someone will be able to help you.

Good luck.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedMar 7, '14 at 9:58p
activeMar 8, '14 at 7:37a
posts3
users3
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase