The following uses a simpler regexp, and it doesn't slurp the file into memory. It's probably faster:
#!/usr/local/bin/perl use warnings; use strict; my $record_start_regexp = qr/^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d:\d\d\d/; sub do_something { print("[\n"); print($_[0]); print("]\n"); } { local $_; my $data; for (;;) { $_ = <DATA>; last if not defined $_; last if /$record_start_regexp/; } while (defined) { $data .= $_; $_ = <DATA>; if (!defined || /$record_start_regexp/) { do_something($data); $data = ''; } } }
In reply to Re: Pimp My RegEx
by ikegami
in thread Pimp My RegEx
by heathen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |