in reply to Stripping page headers
If the header consists of an unknown number of lines terminated by two newlines, change the regex to the following:#!/usr/bin/perl -w use strict; my $file; open DATA, "<somefile.dat" or die "Can't open somefile for reading: $! +\n"; { undef $/; $file = <DATA>; } $file =~ s/^[^\n]+\n[^\n]+\n\n//; close DATA; open NEWFILE, ">newfile.dat" or die "Can't open newfile for writing: $ +!\n"; print NEWFILE $file; close NEWFILE;
$file =~ s/.*?\n\n//;
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
|
|---|