I actually used the Getopt::Long; module to set everything and it worked fine. But I have another problem now I've created three ARGV[] arguments.

$list=$ARGV[0]; if ($list eq "list") { my $chan = $ssh2->channel(); $chan->blocking(1); $chan->shell(); print $chan "cd ..\n"; print $chan "ls\n"; print " $_" while <$chan>; print "Type the name of the directory you would like to enter: "; my $dir = <STDIN>; print $chan "cd '/'$dir\n"; print $chan "ls\n"; print " $_" while <$chan>; } $delete=$ARGV[1]; if ($delete eq "delete") { unlink($delete_file); } $upload=$ARGV[2]; #Send file if ($upload eq "upload") { $ssh2->scp_put($upload_local,$upload_remote) or warn "Could not copy the file"; } $download=$ARGV[3]; #Get file if ($download eq "download") { $ssh2->scp_get($download_remote, $download_local) or warn "Could not copy the file"; }

Its made so that I can call a download or upload of some file or to list all the files in a folder.

The problem I have is that I can't seem to figure out how to set the ARGV part so that I can run any of these arguments at any time. Right now for me to run download for instance I would first have to run list and delete and upload before I could run download.

Is there some way to set the ARGV command to be able to run multiple commands without being dependant on the order by which they are run? So I could run list then download then upload then delete.


In reply to Re^2: CLI with ARGV by WhiskeyJack
in thread CLI with ARGV by WhiskeyJack

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.