in reply to anonymous filehandle for overridden open sub
The key is that variables are passed into functions by reference, so modifying the variable while it is still in @_ will be seen where the variable originally was.sub open { # ... some logging happens here ... return CORE::open($_[0], @_[1..$#_]); }
Note that, as others have pointed out, it is a bad idea to just try to open files and not have an error check in case of failure. See perlstyle for details. Furthermore I think that it is a good idea to switch to 3-arg open: <code>open(my $AFILE, "<", $file)<code> which will keep metacharacters in $file from being wrongly interpreted.
|
|---|