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!
In reply to Re: problem to open a specified path file in open system call
by naikonta
in thread problem to open a specified path file in open system call
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |