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->(); }
In reply to Re^3: Prevent Strings From Being Interpreted As A File Handle
by amon
in thread Prevent Strings From Being Interpreted As A File Handle
by amon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |