Have you looked at Getopt::Simple or the Getopt::Long
These will handle your script with -a or --a options.
Below is a snippet of an example which came from a Win32 service script.
-----use Getopt::Long; my %Config = ( timeout_value => 2, log_file => join( "", Win32::GetFullPathName( $0 ) ), ); $Config{log_file} =~ s/[^.]*?$/log/; Getopt::Long::Configure( "prefix_pattern=(-|\/)" ); $Result = GetOptions( \%Config, qw( install|i remove|r timeout_value|t=i log_file|l=s monitor_sub_dirs|s account_id|user=s account_password|pass=s help|?|h ) ); $Config{help} = 1 if( ! $Result || scalar @ARGV ); if( $Config{install} ) { Install(); exit(); } elsif( $Config{remove} ) { Remove(); exit(); } if( $Config{help} ) { Syntax(); exit(); }
In reply to Re: Running perl functions from a command line
by AcidHawk
in thread Running perl functions from a command line
by wizard341
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |