Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re (tilly) 1: Closing and re-opening the DATA Filehandle

by tilly (Archbishop)
on Apr 05, 2001 at 07:23 UTC ( #70003=note: print w/replies, xml ) Need Help??


in reply to Closing and re-opening the DATA Filehandle

My solution would be to side-step the question with some memoization.
my @Table; { my @_Table; sub LoadTable { unless (@_Table) { local $/; @_Table = map {chomp; hex} split ' ', <DATA>; close DATA; } @Table = @_Table; } }
Issues with this? Well first of all you are assuming that DATA doesn't have too much in it, and you assume that it has something.

But still memoization is a good solution to many problems where you wouldn't have thought it applied at first....

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://70003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2019-08-21 23:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?