I've just tested the program, and added the idea from Mull
#!perl -w use strict; my $params = &GetParameters(); my @dirs = @{ $params->{dir} }; my @file = @{ $params->{file} }; print "\nDIRS:\n\t"; print join("\n\t", @dirs); print "\nFILES:\n\t"; print join("\n\t", @file); # and so on sub GetParameters { my @allowedParams = qw(file dir); die &PrintUsage() unless @ARGV; my $params = {}; # shell contain parameters foreach (@ARGV){ my ($key, $val) = split(/\=/, $_, 2); # split up by the first = # test if $key is a valid parameter unless ($key =~ s/^\-\-//) { # must start with -- die &PrintUsage( "Error: invalid param --$key"); } unless ( grep {lc($key) eq lc($_)} @allowedParams){ die "Error: param $key not allowed\n"; } # maybe do some checks if $val is existing # .... # add param to hashreference $params push (@{ $params->{$key} }, $val); } # for return ($params); } # GetParameters # Added &PrintUsage; thx to [mull] sub PrintUsage{ my $msg = shift || ''; return (<<USAGE); $msg: $0 --dir=/dir1/sdir2 --dir=/dir2/sdir2 --file=README.txt USAGE ; }
Output:
C:\TEMP\test>testParameters.pl --dir=/dir1/sdir2 --dir=/dir2/sdir2 --f +ile=README.txt DIRS: /dir1/sdir2 /dir2/sdir2 FILES: README.txt C:\TEMP\test>

Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"


In reply to Re: File Find by strat
in thread File Find by oaklander

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.