linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "David Jackson" <david.jay.jackson@wcox.com>
To: Linux-Admin <linux-admin@vger.kernel.org>
Subject: Perl : split +sort
Date: Sun,  2 Jun 2002 02:32:57 -0600	[thread overview]
Message-ID: <200206020232.AA812253490@wcox.com> (raw)

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";
}



                 reply	other threads:[~2002-06-02  8:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200206020232.AA812253490@wcox.com \
    --to=david.jay.jackson@wcox.com \
    --cc=linux-admin@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).