snam has asked for the wisdom of the Perl Monks concerning the following question:
what is the fastest way to store a file into an array or a variable? because in my code, I open a directory and find a file that I want to open, and store the name of the file into the variable $d, but by the time when I try to open that file, that file is already gone. so i get an error message saying it can't open the file. Is there anyway to prevent this? like as soon as it sees the file name, open it and store it in a variable to prevent the error? Thanks.foreach my $d(readdir(PROC)){ next if $d !~ /^[0-9]+$/; my $procdir = "/proc/$d"; open(IN, "<$procdir/status") || die "can't open status with$pr +ocdir"; while(<IN>){ @a = split(/\s+/, $_) if /Uid/; $temp[0] = $a[1]; @b = split(/\s+/, $_) if /VmSize/; $temp[1] = $b[1]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fastest way to open a file and stroing it?
by jepri (Parson) on Feb 03, 2003 at 04:55 UTC | |
|
Advisory locking to 'lock' a directory
by Coruscate (Sexton) on Feb 03, 2003 at 05:24 UTC | |
by Abigail-II (Bishop) on Feb 03, 2003 at 09:55 UTC | |
|
Re: fastest way to open a file and storing it?
by Zaxo (Archbishop) on Feb 03, 2003 at 06:00 UTC | |
|
Re: fastest way to open a file and stroing it?
by pg (Canon) on Feb 03, 2003 at 05:36 UTC | |
by snam (Novice) on Feb 03, 2003 at 07:48 UTC | |
|
Re: fastest way to open a file and stroing it?
by BrowserUk (Patriarch) on Feb 03, 2003 at 05:40 UTC |