[32214] in Perl-Users-Digest
Perl-Users Digest, Issue: 3479 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 22 11:09:21 2011
Date: Mon, 22 Aug 2011 08:09:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 22 Aug 2011 Volume: 11 Number: 3479
Today's topics:
Re: how do I create a hash from the list <cartercc@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Aug 2011 06:46:01 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: how do I create a hash from the list
Message-Id: <2791c4b9-ae15-41aa-b9dc-6503a68f8562@z18g2000yqb.googlegroups.com>
On Aug 19, 5:11=A0pm, Nene <rodbas...@gmail.com> wrote:
> I just used regular expressions to parse out an IP and port. Now how
> do I create a hash from the list.
>
> Here is the regex I used:
> perl -ne 'print "$1 $2\n" if /http:\/\/(\S+):(\d+)\/' {} \; | sort |
> uniq
>
> The output of that command is:
> 10.10.24.131 7002
> 10.10.24.142 7504
> 10.10.24.144 7506
> 10.10.24.150 7512
> 10.10.24.151 7413
> 10.10.24.151 7513
> 10.10.24.151 7613
Perl flattens lists, and a hash is just a flattened list with
alternating values. For example:
my %colors =3D ("A","Apple","B","Bannana","C","Cumquat","D","Date");
Alternatively:
my %colors =3D (A =3D> "Apple, B =3D> "Bannana", C =3D> "Cumquat", D =3D>
"Date");
The =3D> operator is just a shorthand for a comma and quote in a list.
CC.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 3479
***************************************