I quickly wrote some sample code below that I hope would be more helpful to set your perl programming on the right track :-D
#!/usr/bin/perl
use Getopt::Long;
use Pod::Usage; # Recomend to use Pod::Usage along with Getopt::Long
use strict;
# Parse command line arguments and assign corresponding variables
GetOptions
(
'f|fruit=s' => \( my $fruit = undef ),
'a|action=s' => \( my $action = undef ),
'g|greet' => \( my $greet = undef ),
);
unless ( defined $action && defined $fruit )
{
pod2usage( -exitval => 1, -output => \*STDERR );
}
# do greeting
print "Hello there!\n" if ($greet);
# multiple fruit possible
my @fruit = split /,/, $fruit;
foreach (@fruit)
{
print "I will $action $_.\n";
# etc...
}
exit(0);
__END__
=pod
=head1 NAME
fruit.pl
=head1 SYNOPSIS
fruit.pl [options]
=head1 ARGUMENTS
The -f and -a options are mandatory. The -g option is optional.
=over 4
=item B<-f|--fruit [name]>
Specify the fruit, multiple fruits possible, separate by comma
=item B<-a|--action [name]>
Specify the action to perform on fruit.
=item B<-g|--greet>
Print the greeting.
=back
=cut
Then you can run the program with command-line options:
perl ./fruit.pl -f apple,orange -a eat -g
perl ./fruit.pl --fruit banana -action sell
...