It's clear that you're working on files in a directory but I'm not sure what are you trying to achieve as you provide a very small amount of information on that. For what you're doing, Perl provides built-in functions so you don't need external program like ls: opendir, readdir, and closedir. Examples (untested),
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;
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,
open FILE, $latest or die "Can't open $latest: $!\n"; ....
Instead, you have to write,
# presume / as path separator my $latest_file = "$path/$latest"; open FILE, $latest_file or die ...;
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.