Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

RE: Using directory handles in recursive functions

by ahunter (Monk)
on Jun 10, 2000 at 22:40 UTC ( #17521=note: print w/replies, xml ) Need Help??

in reply to Using directory handles in recursive functions

In the cases where I've wanted to make file handles local (without using File::Handle :-), I've done the following:
{ local(*FH); open(FH, "<whatever") }
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.

This is also useful for opening an arbitary number of files. Take a reference to the glob before exiting the local block:

{ local(*FH); open(FH, "<whatever") $fh = \*FH; } print $fh "Foo\n";
As an added bonus, the file will be closed automagically when $fh goes out of scope :-)

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...


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://17521]
[Corion]: ambrus: No, you're misunderstanding. If you place content too far on the left/right/top/ bottom, people might not see it because the view is obstructed ;)(
[Corion]: In Amsterdam, the screen went down to the bottom of the stage (60cm above ground) and the seating was on the ground, meaning that the rows in the back couldn't see the bottom of slides.
[Corion]: There also were some columns that meant that maybe you couldn't see the left/right edge of a slide.
[ambrus]: Corion: Sure. I've had a course in a 50 seat lecture hall that has two fucking columns in the middle.
[Corion]: Talking about it, the top should be fairly visible in the situations I've experienced at least. The top is uncomfortable for people in the first three rows, but that's life ;)
[ambrus]: The pillars are there because this is in the 6th floor of building R of BME, which is an attic that was built in after the original building, which is also why the elevator doesn't go that high and the windows are tiny.
[Corion]: ambrus: Hehe ;) Yeah - such real life stuff is far more inconveniencing than wasting display area due to screen ratio problems :)
[ambrus]: Corion: yes, it's a bit tricky. you can try to adjust the slides live to cover only a part of the screen, but it's still hard.
[ambrus]: Corion: two very hard things about presentations I should try to work on if I have twenty times as much free time as in real life are:
[Corion]: That's why I like HTML - it makes it relatively easy to resize stuff. Resizing with Powerpoint is much harder, or at least, I remember it being that way

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2017-09-26 10:14 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.