thricewise has asked for the wisdom of the Perl Monks concerning the following question:
Hello all. I am not new to unix, but very new to perl. I have a nifty little script set up that finds people with an ID of 100,1000,10000 you get the point, but I am now trying to sort it alphabetically by last name and I am running into all kinds of snags, here is the scrpt any help would be appreciated
#!/usr/bin/perl -w use strict; my ($ID, $DP, $LN, $FN, $NM); open(EMPLOYEES,"<employees") || die "Cannot Open"; while(<EMPLOYEES>) { if(/(.*):(1.*):(.*):(.*):(.*)/) { #Supposed to parse $_ $ID = $1; $DP = $2; $LN = $3; $FN = $4; $NM = $5; print $ID; # print $DP; # print $LN; # So I can see if a value is there print $FN; # print $NM; # chomp; (my @f = split(/:/)) == 5 or next; print join("\t", @f[2, 3, 0, 4]), "\n"; } } close(EMPLOYEES)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quick Sort Question
by zwon (Abbot) on Dec 09, 2009 at 20:23 UTC | |
by thricewise (Initiate) on Dec 09, 2009 at 20:48 UTC | |
by almut (Canon) on Dec 09, 2009 at 21:01 UTC | |
by thricewise (Initiate) on Dec 09, 2009 at 21:06 UTC | |
by zwon (Abbot) on Dec 09, 2009 at 21:03 UTC | |
|
Re: Quick Sort Question
by baxy77bax (Deacon) on Dec 09, 2009 at 20:30 UTC |