print "\nH1. Attempt to list files "; foreach $file ( @{$ls1}, @{$ls2}, @{$ls3}, @{$ls4} ) { print "\nH1. $file "; }

$sftp->ls() returns a reference to an array of hashes. You are printing the reference to the hash. Try the example given in the documentation for Net::SFTP::Foreign and let us know how that works. It is printing the 'filename' value in the returned hash. If you leave out the directory name it will list the contents of the current working directory.

my $ls = $sftp->ls('/home/foo') or die "unable to retrieve directory: ".$sftp->error; print "$_->{filename}\n" for (@$ls);

Update: Also I just noticed you are using glob style wildcards inside a regular expression for your ls function call. That won't work as you expect for a regular expression.

$pat4 = $envment . "REQ_*.req.copied"; ... $ls4 = $sftp->ls('/', names_only => 1, wanted=>qr/$pat4/);

In your $pat4 regular expression it is looking for 0 or more copies of '_' followed by any single character ( '.' ) followed by req then any single character, etc. Why not start with a small test of just printing all files then try to get the regular expression working.


In reply to Re: SFTP Foreign Issues using $sftp->ls by Lotus1
in thread SFTP Foreign Issues using $sftp->ls by Vita

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.