If I may suggest, a regex is not the best tool for the job here. Unless there is an overriding reason, it might be easier just to do something along the lines of:
my $filename = "blah.txt"; #replace as needed rename($filename, $filename . '.bak') or die("Unable to rename $filename to $filename.bak: $!\n"); open(INFILE, $filename . '.bak') or die("Can't open $filename.bak for input: $!\n"); open(OUTFILE, '>' . $filename) or die("Can't open $filename for output: $!\n"); my $linecount = 0; while ($line = <INFILE>) { print(OUTFILE $line) if ($linecount); $linecount++; } close(INFILE); close(OUTFILE);
Two references that cover this and more that I use frequently are the perl FAQs and Perl Cookbook, and there are others here and about.
Hope that helps. I look forward to seeing the responses of others as well.
In reply to Re: Regex
by atcroft
in thread Delete the first line of a file ?
by cored
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |