CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: How to handle different amout of arguments in Perl: Edit Log



digioleg54
User

May 15, 2017, 12:58 PM


Views: 2334
How to handle different amout of arguments in Perl

When I convert shell to Perl I run into situation that the program can get different amount of arguments, and the second argument can be a date, report name, or directory.

How can I handle such situation in Perl?
I know I can use GetOpts.something like

Code
sub option 
{
my %options;
GetOpts 'a:b:c', %options;

if (defined $options{a})
{
my $date = $options{a};
}
(and so on)
}


But the question is if the whole program will know variables from sub option?

Thanks


(This post was edited by digioleg54 on May 15, 2017, 1:40 PM)


Edit Log:
Post edited by digioleg54 (User) on May 15, 2017, 1:40 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives