Perl : split +sort
Howdy --
What I need to do the the contact list is split the city/state fields and than sort by state. The record format is below.
And it would be nice to print the state name before each state group.
Thanks in advance
1st Concept Internet, Inc.
1000 West McNab Road Suite #109
Pompano Beach, Florida
33069
--- Quickie perl script using a2p looks like this ---
#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# this emulates #! processing on NIH machines. # (remove #! line above if indigestible)
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
# process any FOO=bar switches
$FS = ' '; # set field separator $, = ' '; # set output field separator $\ = "\n"; # set output record separator
$/ = "\n\n";
$FS = "\n";
$, = "\n";
while (<>) {
chomp; # strip record separator
($Fld1,$Fld2,$Fld3,$CityState,$Fld5) = split($FS, $_, 9999);
print $Fld1, $Fld2, $Fld3, $CityState, $Fld5 . "\n";
}