radnus has asked for the wisdom of the Perl Monks concerning the following question:
#!/perl/me -w use strict; use FileHandle; my $i = 0; # Get the current Process Id my $proc = getpgrp(0); # Create 10 files.. while ($i < 10) { # Get a new File Handle my $fh = new FileHandle(); # Count the File Handle for this process... system ("ls -l /proc/$proc/fd/ | wc -l"); # Open a new File sysopen ($fh, "/tmp/$i", O_RDWR) or die "$!"; # Write something to the file print $fh "stuff \n"; #increment counter, to create a newer file. $i++; ## NO CLOSE... }
I was expecting it to go UP by 1 each time in the loop, but it stayed at 5. Why?/tmp> ./perl junk2.pl 5 5 5 5 5 5 5 5 5 5
20100721 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl File Handle Count not working as expected, why?
by Corion (Patriarch) on Jul 14, 2010 at 17:50 UTC | |
by radnus (Novice) on Jul 14, 2010 at 18:11 UTC | |
by ikegami (Patriarch) on Jul 14, 2010 at 18:30 UTC | |
Re: Perl File Handle Count not working as expected, why?
by jwkrahn (Abbot) on Jul 14, 2010 at 17:57 UTC | |
by almut (Canon) on Jul 14, 2010 at 18:10 UTC | |
by radnus (Novice) on Jul 14, 2010 at 18:23 UTC | |
Re: Perl File Handle Count not working as expected, why?
by TedPride (Priest) on Jul 15, 2010 at 05:27 UTC |
Back to
Seekers of Perl Wisdom