Software >> Development >> Languages >> Perl >> How to build usage display and parse options using forward slash /

use File::Basename; $prog = basename(replacebegin:content:replaceend); %Bytes; # eg. $Bytes{'01'} etc %Jobs; # eg. $Jobs{'01'} etc if($#ARGV < 2) { die "\nUsage:\n\n\ $prog /s=dd-mmm-yyyy /e=dd-mmm-yyyy /f=text|html /o=outfile \n\n /s\tstart date\n /e\tend date\n /f\toutput format either text or html\n /o\toutput file name\n"; } for($hr=0;$hr<24;$hr++) { $Bytes{"$hr"} = 0; $Jobs{"$hr"} = 0; } foreach $a (@ARGV) { $a =~ s/^\///gi; ($argname,$argval) = split(/=/,$a); $inputarg{$argname} = $argval; } if ( defined $inputarg{'s'} ) { printf "start date = %s\n",$inputarg{'s'}; } if ( defined $inputarg{'e'} ) { printf "end date = %s\n",$inputarg{'e'}; } if ( defined $inputarg{'f'} ) { printf "report format = %s\n",$inputarg{'f'}; } if ( defined $inputarg{'o'} ) { printf "output file = %s\n",$inputarg{'o'}; }

Deals @yubeshop.com