in reply to problem to open a specified path file in open system call
One thing to note: since you're working on the current directory (wherever it is), you have to use the original path to work on a file. For example, the following is wrong,my $dir = shift; # get the first command line arg my $path = "/remote/scm/rsync/builds/$arg/FailedInformal"; opendir DIR, $path or die "Can't open $path: $!\n"; my @releases = grep {/^\d/} readdir DIR; # NOW, it's up to you what you want with files you find # in @releases # get the latest three my @three = @releases[-1,-2,-3]; # get only the very latest my $latest = $relreases[-1]; .... # and closing the DIR handle is good closedir DIR;
Instead, you have to write,open FILE, $latest or die "Can't open $latest: $!\n"; ....
As to the error message, it just says what the perl interpreter thinks, the file doesn't exist. Check it manually if that's not what you think.# presume / as path separator my $latest_file = "$path/$latest"; open FILE, $latest_file or die ...;
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problem to open a specified path file in open system call
by Anonymous Monk on Jul 14, 2007 at 13:03 UTC | |
by naikonta (Curate) on Jul 14, 2007 at 13:31 UTC | |
by blazar (Canon) on Jul 15, 2007 at 07:36 UTC | |
by naikonta (Curate) on Jul 15, 2007 at 13:27 UTC | |
by almut (Canon) on Jul 14, 2007 at 13:46 UTC |