Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Prevent Strings From Being Interpreted As A File Handle

by amon (Scribe)
on Apr 27, 2014 at 14:33 UTC ( [id://1083998]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Prevent Strings From Being Interpreted As A File Handle
in thread Prevent Strings From Being Interpreted As A File Handle

This is clever. I like it.

So we'd end up with something inconvenient like

sub invoke_static { my ($class, $method, @args) = @_; no strict 'refs'; # I'd like to only localize *{$class}{IO}, # but we can't have everything, right? local *{$class}; $class->$method(@args); }

or something insane like

sub safe_from_evil_filehandles(&) { my ($cb) = @_; my @evil_globs; ... # walk through %:: and list all globs # where *{$entry}{IO} is defined # unless they're OK like "STDOUT" my $localizer; $localizer = sub { return $cb->() unless @evil_globs; local *{shift @evil_globs}; return $localizer->(); }; return $localizer->(); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found