Question: I need help with implementing a command line switch in PERL to reverse sort a list of inputs. @ARGV seems to be what should be
I need help with implementing a command line switch in PERL to reverse sort a list of inputs. @ARGV seems to be what should be used but I can't seem to figure it out.
This is the sorter program as it is currently.
use warnings;
use strict;
sub main
{
#Declare and initialize with argument words
my @words = sort @ARGV;
#Sort the array
@words = sort @words;
#Checking for correct data
if (@words <= 1) {
print "Invalid command line arguments to program. Please supply two or more strings to sort. "
} else {
foreach my $word(@words) {
print "$word ";
}
}
print " ";
}
main ();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
