in reply to Using directory handles in recursive functions
I think my works with file globs as well, but I'm not sure, as this is one instance where local() seems more intuitive (!) to me.{ local(*FH); open(FH, "<whatever") }
This is also useful for opening an arbitary number of files. Take a reference to the glob before exiting the local block:
As an added bonus, the file will be closed automagically when $fh goes out of scope :-){ local(*FH); open(FH, "<whatever") $fh = \*FH; } print $fh "Foo\n";
I would guess that opendir() and so on will work fine with this. I haven't tried it, of course, but there's no reason it shouldn't. Note that the asterix in local(*FOO) is important. local(FOO) has a different meaning...
Andrew.
|
|---|