Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I finally got my little template working with this module. I found all the discussion and example code necessary, including cpan paragraph

I'm trying to use github to post bulky modules. author's github repo is the greater context in which this works:

sub get_html_filename{ use Net::SFTP::Foreign; use File::Basename; use Cwd; use 5.01; my $sftp = shift; # get working directory my $dir = getcwd(); my $word = basename($dir); say "word is $word"; # get files from /pages my $ls = $sftp->ls("/pages", wanted => qr/$word/) or warn "unable to retrieve ".$sftp->error; print "$_->{filename}\n" for (@$ls); my @remote_files = map { $_->{filename} } @$ls; say "files are @remote_files"; my $rref = \@remote_files; my $filetype = "html"; my $old_num = highest_number($rref, $filetype, $word); print "old num is $old_num\n"; my $new_num = $old_num + 1; my $html_file = $word.$new_num.'.'.$filetype; return $html_file; }

Abridged output from stdout:

$ perl powell1.pl title is powell values are [correct] object created, back in main word is powell powell1.html powell2.html files are powell1.html powell2.html old num is 2 new file is powell3.html $

The page, populated by mundane matters, accomplishes its humble task: page posted (no porn). How to dereference a reference to an array of hashrefs is something that runrig posted on 2013 node, to wit:

my $ls = $sftp->ls('/home/ftptest/inbound', no_wanted => qr/^\./ ); my @names_and_sizes = map { { filename => $_->{filename}, size => $_-> +{a}->size } } @$ls; # or... my %size = map { $_->{filename} => $_->{a}->size } @$ls;

To shoehorn this into an array of filenames, I turned this into:

my @remote_files = map  { $_->{filename} } @$ls;

and I was back in business. Thanks all for comments and code.


In reply to Re^4: instantiating an SFTP object by Aldebaran
in thread instantiating an SFTP object by Aldebaran

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 00:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found