in reply to Re: reading __DATA__ more than once
in thread reading __DATA__ more than once
{ my $offset; BEGIN { $offset = tell DATA } sub build_data { seek DATA, $offset, 0; return [ <DATA> ]; } }
That way, even if someone else touches DATA before build_data is called the first time (aka a race condition), it still produces the correct result.
Update: Good point - I stand corrected.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^2: reading __DATA__ more than once
by japhy (Canon) on Nov 16, 2002 at 15:24 UTC |