The only thing I'm sort of unsure of is, how would I get the name in my text file into @sorted?
Also, would it be possible to use this perl code in the middle of a shell script? I think I remember someone telling me I could do something like this but I'm not sure of the tags I need to specify for this to work. Thanks!
in order to work your command, you have to get the contents of file in the array @not_sorted. So read the file as follows:
open (NAMES_FILE, "< /path/to/file") or die "Failed to read file : $! ";
my @not_sorted = <NAMES_FILE>; # read entire file in the array
close (NAMES_FILE);
now using your statement you would get the sorted names in the @sorted array.
This would be a Perl script, so you will have to invoke it from your shell script. But if you want to access the sorted list in your shell script, then you will have to store it somewhere (in a file).
Alternatively, think of doing the sorting using shell commands and tools. This way, you need not invokde a diffeerent Perl script.
@bigearsbilly: I thought about that but I was told that the sort in shell does funny things and that perl would be more reliable. Maybe I'll try that and check out the results