[32213] in Perl-Users-Digest
Perl-Users Digest, Issue: 3478 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 21 16:09:25 2011
Date: Sun, 21 Aug 2011 13:09:09 -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 Sun, 21 Aug 2011 Volume: 11 Number: 3478
Today's topics:
Re: gui <nickbergeronsemail@gmail.com>
Hi, do you think this perl barcode script is usefull? <lordyumyum@gmail.com>
how do I create a hash from the list <rodbass63@gmail.com>
Re: how do I create a hash from the list <rweikusat@mssgmbh.com>
Re: how do I create a hash from the list <jurgenex@hotmail.com>
Re: how do I create a hash from the list <ben.usenet@bsb.me.uk>
Re: how do I create a hash from the list sln@netherlands.com
Re: Matching repetitions with /g <derykus@gmail.com>
Re: Matching repetitions with /g sln@netherlands.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Aug 2011 07:48:47 -0700 (PDT)
From: Miro <nickbergeronsemail@gmail.com>
Subject: Re: gui
Message-Id: <87128055-9ea3-4829-b5b1-71ffe0381b6b@br5g2000vbb.googlegroups.com>
On Aug 17, 7:43=A0pm, RedGrittyBrick <RedGrittyBr...@spamweary.invalid>
wrote:
> On 16/08/2011 17:05, Miro wrote:> On Aug 15, 12:31 am, robin<r...@thevoid=
1.net> =A0wrote:
> >> anyone know of any NEW perlguitoolkits?
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^^^
>
>
>
> > wX is pretty nice.
>
> =A0From CPAN:
> 0.03 =A0Mon Dec 04 15:00:01 2000 - First public release
>
> Does that really count as NEW?
>
> --
> RGB
Not at all, but number one, this obviously isn't the most productive
question on here and isn't really worth much time, and number two,
it's had a lot of good tolls made for it as of late and they aren't
really cranking out (good) GUI toolkits every minute.
------------------------------
Date: Sat, 20 Aug 2011 19:51:55 -0700 (PDT)
From: gerald krug <lordyumyum@gmail.com>
Subject: Hi, do you think this perl barcode script is usefull?
Message-Id: <280613e8-c06c-42ea-8aaa-534741e86594@f1g2000pre.googlegroups.com>
http://boughtupcom.freeservers.com/cgi/CRcode/acqcode.pl
Maybe I should get a life :)
------------------------------
Date: Fri, 19 Aug 2011 14:11:30 -0700 (PDT)
From: Nene <rodbass63@gmail.com>
Subject: how do I create a hash from the list
Message-Id: <900592ba-99b5-4f1f-b633-663719b7eac1@v7g2000vbk.googlegroups.com>
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
------------------------------
Date: Fri, 19 Aug 2011 22:22:49 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: how do I create a hash from the list
Message-Id: <878vqp85au.fsf@sapphire.mobileactivedefense.com>
Nene <rodbass63@gmail.com> writes:
> 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
'$hash{$1} = $2 if ...' ?
------------------------------
Date: Fri, 19 Aug 2011 18:52:57 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: how do I create a hash from the list
Message-Id: <io4u475v8j38mmm8sg41u85vnn71cgvquo@4ax.com>
Nene <rodbass63@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.
There are many different ways to create many different hashes. What is
the desired structure/content of that hash (you forgot to tell us....)?
jue
------------------------------
Date: Sat, 20 Aug 2011 04:20:24 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: how do I create a hash from the list
Message-Id: <0.05e640e9e45c1f2141cd.20110820042024BST.87ippsahvr.fsf@bsb.me.uk>
Nene <rodbass63@gmail.com> writes:
> 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 |
Looks like there might be a missing / in there. See below...
> uniq
While you say more about the hash you want to create, here's a tip: you
don't have to use // for regular expressions. If you precede the
expression with 'm' you can use something that is more convenient
if /http:\/\/(\S+):(\d+)\//
becomes
if m!http://(\S+):(\d+)/!
or even
if m{ http:// (\S+) : (\d+) / }x
(the trailing x lets you add space).
<snip>
--
Ben.
------------------------------
Date: Sat, 20 Aug 2011 10:14:23 -0700
From: sln@netherlands.com
Subject: Re: how do I create a hash from the list
Message-Id: <5oqv471l7cae64nncmcg59ggjfu28jhjsu@4ax.com>
On Fri, 19 Aug 2011 14:11:30 -0700 (PDT), Nene <rodbass63@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
You could create an array for the ports.
-sln
-----------------------
use strict;
use warnings;
my @data = (
'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',
);
my %gameservers;
for (sort @data)
{
if (/^(\S+)\s+(\d*)$/) {
push @{$gameservers{$1}}, $2;
}
}
for my $addr (sort keys %gameservers)
{
print "adress: $addr ports: ";
for my $port (sort @{$gameservers{$addr}}) {
print "$port, ";
}
print "\n";
}
-------------------
Output:
adress: 10.10.24.131 ports: 7002,
adress: 10.10.24.142 ports: 7504,
adress: 10.10.24.144 ports: 7506,
adress: 10.10.24.150 ports: 7512,
adress: 10.10.24.151 ports: 7413, 7513, 7613,
------------------------------
Date: Fri, 19 Aug 2011 13:42:37 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Matching repetitions with /g
Message-Id: <5084ffc0-5591-4d48-9b98-a373a9fa876f@j14g2000prh.googlegroups.com>
On Aug 18, 11:08=A0am, Jim Gibson <jimsgib...@gmail.com> wrote:
> In article
> <7d42dfd1-68c0-4c1c-a6d4-75344a11c...@x11g2000yqx.googlegroups.com>,
>
> Wolfram Humann <w.c.hum...@arcor.de> wrote:
> > Can I modify
>
> > > perl -E'@a=3D "# + 17 =A0-18 =A0+19 =A0- 20 #" =3D~ /^ \# \s* ([+-] \=
s? \d+ \s+)* \#
> > > /xg; say qq(@a)'
> > > - 20
>
> > to capture all 4 numbers?
>
> Yes. You need to remove the elements that anchor your pattern to the
> beginning and end of the string, and eliminate the repeat modifier '*'
> for the sub-pattern that matches the numbers:
>
> perl -E'@a=3D ("# + 17 =A0-18 =A0+19 =A0- 20 #" =3D~ /(\s* [+-] \s? \d+)/=
xg); say
> qq(@a)'
> =A0+ 17 =A0 -18 =A0 +19 =A0 - 20
Or, it's slower but you could even
workaround the anchoring:
perl -E '@a=3D "# + 17 -18 +19 - 20 #" =3D~ /(?:^|) \#? \s* ([+-] \s?
\d+ \s+) \#? /xg; say qq(@a)'
--
Charles DeRykus
------------------------------
Date: Sat, 20 Aug 2011 09:39:34 -0700
From: sln@netherlands.com
Subject: Re: Matching repetitions with /g
Message-Id: <a2mv47plgi2c37oqkqqkri4ivufcj5mqb9@4ax.com>
On Fri, 19 Aug 2011 13:42:37 -0700 (PDT), "C.DeRykus" <derykus@gmail.com> wrote:
>On Aug 18, 11:08 am, Jim Gibson <jimsgib...@gmail.com> wrote:
>> In article
>> <7d42dfd1-68c0-4c1c-a6d4-75344a11c...@x11g2000yqx.googlegroups.com>,
>>
>> Wolfram Humann <w.c.hum...@arcor.de> wrote:
>> > Can I modify
>>
>> > > perl -E'@a= "# + 17 -18 +19 - 20 #" =~ /^ \# \s* ([+-] \s? \d+ \s+)* \#
>> > > /xg; say qq(@a)'
>> > > - 20
>>
>> > to capture all 4 numbers?
>>
>> Yes. You need to remove the elements that anchor your pattern to the
>> beginning and end of the string, and eliminate the repeat modifier '*'
>> for the sub-pattern that matches the numbers:
>>
>> perl -E'@a= ("# + 17 -18 +19 - 20 #" =~ /(\s* [+-] \s? \d+)/xg); say
>> qq(@a)'
>> + 17 -18 +19 - 20
>
>Or, it's slower but you could even
>workaround the anchoring:
>
>perl -E '@a= "# + 17 -18 +19 - 20 #" =~ /(?:^|) \#? \s* ([+-] \s?
>\d+ \s+) \#? /xg; say qq(@a)'
Its meaningless that Wolfram used the /g modifier while anchoring the
regex with a must ^ unless it were used in conjunction with \G assertion.
So the anchors ^ and # would seem to be for validation of what must come
between. It would then be a wasted effort to exclude them, and at the
same time, a wasted effort to include them using /g in this context.
For capturing purposes,
/(?:^|) \#? \s* ([+-] \s? \d+ \s+) \#? /xg
is identical to
/([+-] \s? \d+ \s+)/xg
Both of which when applied to this string
"adfsg+ 17 -18 dsfgh 92+19 - 20 "
return the list
('+ 17 ', '-18 ', '+19 ', '- 20')
-sln
------------------------------
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 3478
***************************************