#!/usr/bin/perl use warnings; # Get names print "Enter a new-line separated list of names and end with end-of-input (ctrl-d):\n"; @names = ; # Get command print "Please enter a command (sort, reverse, concatenate): "; chomp ($action = ); # Perform appropiate command if ($action eq "sort") { print sort @names; } elsif ($action eq "reverse") { print reverse @names; } elsif ($action eq "concatenate") { chomp @names; foreach (@names) # $_ default implied - same as foreach $_ (@names) { $name_string .= "$_"; } print "$name_string\n"; } else { print "Command not recognized.\n"; } # Done print "Thank you!\n";