In below code I have tried using Getopt::Std, where i am trying to check if all options are provided or not and I am trying to make "-x" ($dest_file) mandatory,
Please check my code if its up to the general standard or not? Any improvement please let me know.
use strict;
use warnings;
use Getopt::Std;
my %options;
if (scalar @ARGV < 3) {usage()};
sub usage
{
print STDERR << "EOF";
\nThis program does...
usage: $0 [-hcfo]
-h : this (help) message
-c : config file
-o : xcf release file
-x : output file
EOF
exit;
}
getopts ("hc:f:o:", \%options);
usage() if $options{h};
my $source_file = $options{o} || 'as.xcf';
my $config_file = $options{c} || 'config.ini';
my $dest_file = $options{x} || usage();
[\code]
Cheers
I haven't mess with perl at all, but I see two things I would do different:
I may be wrong but shouldn't this be STDOUT since it's not an error? :
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)