When executing the attatched code, entering f returns:
Arthur Putie:923-835-8745:923-812-6789:23 Wimp Lane, Kensington, DL 38758:8/31/69:126000
Barbara Kertz:385-573-8326:385-555-8321:832 Ponce Drive, Gary, IN 83756:12/1/46:268500
Betty Boop:245-836-8357:245-876-7656:635 Cutesy Lane, Hollywood, CA 91464:6/23/23:14500
Ephram Hardy:293-259-5395:293-222-3334:235 CarltonLane, Joliet, IL 73858:8/12/20:56700
When entering l returns the same as entering f, sort based on first name.
print "Please choose either first or last name (f/l): ";
$type = <>;
chomp($type);
if ( $type == "f" ) {
system("sort list.txt");
} elsif ( $type == "l" ) {
system("sort -k2 list.txt");
} else {
print "Choice not recognized.\n";
}
However, if I execute the commands manually in UNIX, then the commands come out sorted as they should be, ([sort list.txt] is first name alphabatized, [sort -k2 list.txt] is last name aplphabetized).
Any ideas for why this is happening, or workarounds to fix it? I am new to perl, so I would prefer to stick to UNIX command alternatives, instead of pure perl script solutions.