in reply to Record separator question
Remember: the value of $/ is a string, not a regex. awk has to be better for something. :-)
Ok - so my suggestion would be to slurp in the entire thing and then split on your regex.
Hope that helps - L~Rlocal $/ = undef; my $record = <INPUT>; my @chunks = split /regex/ , $record; for my $chunk ( @chunks ) { my @lines = split /\n/ , $chunk; }
Update: If for some reason you need to keep the header information - do something like this:
local $/ = undef; my $record = <INPUT>; my @chunks = split /(regex)/ , $record; while ( @chunks ) { my $header = shift; my $chunk = shift; my @lines = split /\n/ , $chunk; }
|
|---|