in reply to can I make my regex match first pattern instead of last?
local $/=undef; my $DataToParse = <DATA>; ... exit();
As GrandFather points out, you should be cautious about slurping files. When you do use slurping it is worth getting into the habit of making the local $/=undef; really local rather than applying from that point in your script onwards so as to avoid nasty surprises further down your code. You can do this either inside a bare code block
my $DataToParse; { local $/; $DataToParse = <DATA>; }
or, perhaps better, a do block
my $DataToParse = do { local $/; <DATA>; };
I hope this is of interest.
Cheers,
JohnGG
Update: Just noticed a horrible cut'n'paste error, there should not have been a my in the bare code block. Corrected.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: can I make my regex match first pattern instead of last?
by kleucht (Beadle) on Oct 25, 2008 at 04:35 UTC |