[30122] in Perl-Users-Digest
Perl-Users Digest, Issue: 1365 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 16 03:09:41 2008
Date: Sun, 16 Mar 2008 00:09:07 -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, 16 Mar 2008 Volume: 11 Number: 1365
Today's topics:
Re: comparing a 2D array <szrRE@szromanMO.comVE>
Re: FAQ 5.28 How can I read in an entire file all at on <szrRE@szromanMO.comVE>
Re: FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths <szrRE@szromanMO.comVE>
Re: FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths <ben@morrow.me.uk>
Re: FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths <hjp-usenet2@hjp.at>
Re: Fastest way to find a match? <jm@nospam.fr>
Re: Fastest way to find a match? <ben@morrow.me.uk>
Re: handle tab-delimited file <benkasminbullock@gmail.com>
Re: help with a regex <savagebeaste@yahoo.com>
HTML parsing <iiuu66@yahoo.com>
Re: HTML parsing <jurgenex@hotmail.com>
new CPAN modules on Sun Mar 16 2008 (Randal Schwartz)
Re: Pattern extraction <szrRE@szromanMO.comVE>
Re: Pattern extraction <someone@example.com>
Re: regular expression with split goes wrong ? <benkasminbullock@gmail.com>
Variables interpolated in character classes? <lonewolf@well.com>
Re: Variables interpolated in character classes? <someone@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 Mar 2008 12:47:47 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: comparing a 2D array
Message-Id: <frh954013bb@news2.newsguy.com>
Abigail wrote:
> _
> Rose (rose@russ.org) wrote on VCCCVIII September MCMXCIII in
> <URL:news:frc0n7$ror$1@ijustice.itsc.cuhk.edu.hk>:
> ?? For the following 2D array comparison codes modified from perllol
> google ?? search, I wonder why the output generated is not what I
> expected. Could ?? anybody tell me what i should modify in order to
> have an exact match of all ?? the attributes of a row from an
> individual file? Thanks a lot~ ??
> ??
> ??
> ?? #!/usr/bin/perl
> ??
> ?? use warnings;
> ??
> ?? $usage='prog t1 t2 cmpname';
> ?? die "Usage: $usage\n" if $#ARGV < 1;
> ??
> ?? $outname = $ARGV[2];
> ?? $file1 = $ARGV[0];
> ?? $file2 = $ARGV[1];
> ?? $cmpcout = $outname . ".cmpofcmp.xls";
> ??
> ?? open(FP1, $file1);
> ?? open(FP2, $file2);
> ?? open(CMP, ">$cmpcout");
>
> You are blindly assuming that the open will succeed. What if an input
> file doesn't exist, or if you don't have permission to open the output
> file?
>
> ??
> ?? $line = <FP1>; #get header
> ?? while ($line ne "") {
>
> Eh, did you by any chance follow a Perl course organized by HP
> education?
> They have the only books I've encountered that don't use the
> canonical way
> of iterating over a file:
>
> while ($line = <FP1>) {
> ...
> }
>
> But I wouldn't use bare file handles any more. With any Perl from the
> current century, you could write:
>
> open my $fh, '<', $file or die "open: $!";
> while (my $line = <$fh>) {
> # Do something with $line
> }
> close $fh or die "close: $!";
>
> ?? $line = <FP1>;
> ?? @attr1 = split(/[\t ]+/, $line);
> ?? push @row1, [ @attr1 ];
> ?? }
>
>
> ??
> ?? $line = <FP2>; #get header
> ?? while ($line ne "") {
> ?? $line = <FP2>;
> ?? @attr2 = split(/[\t ]+/, $line);
> ?? push @row2, [ @attr2 ];
> ?? }
> ??
> ?? for $aref1 (@row1) {
> ?? for $aref2 (@row2) {
> ?? if (@$aref1 == @$aref2) {
> ?? print "@$aref1\n";
>
> This just compares whether $aref1 and $aref2 point to arrays of the
> same length.
>
> You should compare each element individually.
>
> ?? }
> ?? }
> ?? }
>
> Untested code:
>
> LOOP:
> my $equal = 1;
> foreach my $row1 (@row1) {
> foreach my $row2 (@row2) {
> unless (@$row1 == @$row2) {
> $equal = 0;
> last LOOP;
> }
> for (my $i = 0; $i < @$row1; $i ++) {
> my $elem1 = $$row1 [$i];
> my $elem2 = $$row2 [$i];
> unless ($elem1 eq $elem2) {
> $equal = 0;
> last LOOP;
> }
> }
> }
> }
>
> say "Arrays are equal" if $equal;
>
>
>
> Abigail
> --
> A perl rose: perl -e '@}>-`-,-`-%-'
How about this for comparign a "2D" array?
use strict;
my @a1 = ( [qw/A B C/], [qw/D E F/], [qw/G H I/] );
my @a2 = ( [qw/A B C/], [qw/D E F/], [qw/G H I/] );
my $matches =
@a1 == grep { my $i = $_;
@{$a1[$i]} == grep {
$a1[$i][$_] eq $a2[$i][$_];
} (0..$#{$a1[$i]})
} (0..$#a1);
print $matches ? 'Yep' : 'Nope';
$match is true if ALL the elements match, false if not.
This can easily be expanded to handle more "dimentions" as well:
use strict;
my @a1 = ( [ [qw/A B C/], [qw/D E F/] ], [ [qw/G H I/], [qw/J K
L/] ] );
my @a2 = ( [ [qw/A B C/], [qw/D E F/] ], [ [qw/G H I/], [qw/J K
L/] ] );
my $matches =
@a1 == grep { my $i = $_;
@{$a1[$i]} == grep { my $j = $_;
@{$a1[$i][$j]} == grep {
$a1[$i][$j][$_] eq $a2[$i][$j][$_];
} (0..$#{$a1[$i][$j]})
} (0..$#{$a1[$i]})
} (0..$#a1);
print $matches ? 'Yep' : 'Nope';
And so on, for as many levels as you need. Best of all, it's technically
a one liner, though it is obviously more readable written as above :-)
--
szr
------------------------------
Date: Sat, 15 Mar 2008 12:04:32 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: FAQ 5.28 How can I read in an entire file all at once?
Message-Id: <frh6k10vj9@news2.newsguy.com>
PerlFAQ Server wrote:
[...]
> $all_of_it = read_file($filename); # entire file in scalar
> @all_lines = read_file($filename); # one line perl element
^^^^
s/perl/per/ ?
[...]
--
szr
------------------------------
Date: Sat, 15 Mar 2008 12:56:57 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work?
Message-Id: <frh9m90144q@news2.newsguy.com>
PerlFAQ Server wrote:
[...]
> Either single-quote your strings, or (preferably) use forward
> slashes. Since all DOS and Windows versions since something like
> MS-DOS 2.0 or so have treated "/" and "\" the same in a path,
Not all DOS and Windows applications treat "/" the same as "\" in a
path:
Different:
C:\Temp>cd /
C:\Temp>cd \
C:\>
C:\>dir C:\temp
Volume in drive C is SR 1
Volume Serial Number is 1D73-1B0A
Directory of C:\temp
01/26/2005 15:43 PM <DIR> .
01/26/2005 15:43 PM <DIR> ..
[...]
2 File(s) 2,188 bytes
2 Dir(s) 2,678,390,784 bytes free
C:\>dir C:/temp
Parameter format not correct - "emp".
Same:
C:\>attrib C:\temp
C:\Temp
C:\>attrib C:/temp
C:\Temp
Point being you can not take for granted which application does and
doesn't unless you reliably know ahead of time. Not an issue with Perl
of course, and it allows for portable code. Then again, C++ also allowed
"/" in path names IIRC.
--
szr
------------------------------
Date: Sat, 15 Mar 2008 20:50:33 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work?
Message-Id: <pdpta5-c01.ln1@osiris.mauzo.dyndns.org>
Quoth "szr" <szrRE@szromanMO.comVE>:
> PerlFAQ Server wrote:
> [...]
> > Either single-quote your strings, or (preferably) use forward
> > slashes. Since all DOS and Windows versions since something like
> > MS-DOS 2.0 or so have treated "/" and "\" the same in a path,
>
> Not all DOS and Windows applications treat "/" the same as "\" in a
> path:
All Win32 API calls allow either / or \. cmd.exe, and programs designed
to be called from cmd (in particular, programs with DOS-style /FOO
options) insist on \. Some NT API calls require \, but AFAIK it's not
possible to call these from Perl.
A simple rule for a Perl program is anything that is invoking an
external command (including Win32::Process) should use solely \, and
anything else should use solely /.
Ben
------------------------------
Date: Sat, 15 Mar 2008 21:32:14 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 5.35 Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work?
Message-Id: <slrnftocie.6vl.hjp-usenet2@hrunkner.hjp.at>
On 2008-03-15 19:56, szr <szrRE@szromanMO.comVE> wrote:
> PerlFAQ Server wrote:
> [...]
>> Either single-quote your strings, or (preferably) use forward
>> slashes. Since all DOS and Windows versions since something like
^^^^^^^^
>> MS-DOS 2.0 or so have treated "/" and "\" the same in a path,
>
> Not all DOS and Windows applications treat "/" the same as "\" in a
^^^^^^^^^^^^
> path:
Please note the difference between "all DOS and Windows versions" and
"all DOS and Windows applications".
>
> Different:
>
> C:\Temp>cd /
>
> C:\Temp>cd \
It is well known that the DOS/Windows shell treats them differently.
That's irrelevant for perl except for those functions which invoke a
shell (system, qx, open pipe, ...).
In a perl script,
chdir('/');
works just the same as
chdir('\\');
> Point being you can not take for granted which application does and
> doesn't unless you reliably know ahead of time.
"Applications" are not the point of this FAQ.
> Not an issue with Perl of course,
Then why do you mention this issue?
> and it allows for portable code. Then again, C++ also allowed "/" in
> path names IIRC.
Almost certainly, yes. The *OS itself* allows it, so it works in any
program which doesn't actively prevent it.
hp
------------------------------
Date: Sat, 15 Mar 2008 19:10:57 +0100
From: jm <jm@nospam.fr>
Subject: Re: Fastest way to find a match?
Message-Id: <47dc1131$0$21151$7a628cd7@news.club-internet.fr>
Michele Dondi a écrit :
> On Wed, 12 Mar 2008 16:34:08 -0700 (PDT), bukzor
> <workitharder@gmail.com> wrote:
>
>> I'm trying to find the fastest way in perl to see if a name contains
>> another.
> [...]
>> so far, I'm using
>>
>> foreach $t (keys %A) {
>> $v = $B;
>> $v = s/$t//;
>> if ($v ne $B) {
>
> Funniest way I've seen thus far to check for a match!
>
>> print "MATCH"
>
> How 'bout
>
> use List::Util 'first';
>
> # ...
>
> my @rx=map qr/\Q$_\E/ => @A;
> say "match!" if first { $B ~~ $_ } @rx;
>
> ?
>
> L::U is XS and should be pretty fast.
>
>
> Michele
I didnot find ~~ in man perlop.
Is this a perl operator?
or a L::U operator?
------------------------------
Date: Sat, 15 Mar 2008 18:29:10 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Fastest way to find a match?
Message-Id: <m4hta5-ha02.ln1@osiris.mauzo.dyndns.org>
Quoth jm <jm@nospam.fr>:
> Michele Dondi a écrit :
> >
> > use List::Util 'first';
> >
> > # ...
> >
> > my @rx=map qr/\Q$_\E/ => @A;
> > say "match!" if first { $B ~~ $_ } @rx;
> >
> > ?
> >
> > L::U is XS and should be pretty fast.
>
> I didnot find ~~ in man perlop.
>
> Is this a perl operator?
> or a L::U operator?
It's the new 'smart match' operator in perl 5.10. In the case above,
since $_ is always a regular expression, it is equivalent to =~; so
print "match!\n" if first { $B =~ $_ } @rx;
Ben
------------------------------
Date: Sun, 16 Mar 2008 04:00:28 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: handle tab-delimited file
Message-Id: <fri60s$9l4$2@ml.accsnet.ne.jp>
On Sat, 15 Mar 2008 14:10:12 +0000, Tad J McClellan wrote:
> \s matches tab and space (and 3 other characters).
Don't forget your Ogham space mark:
#!/usr/bin/perl
use warnings;
use strict;
use Unicode::UCD 'charinfo';
sub count_match
{
my ($re)=@_;
my $c;
for my $n (0x00 .. 0xD7FF, 0xE000 .. 0xFDCF, 0xFDF0.. 0xFFFD) {
if (chr($n) =~ /$re/) {
my $ci = charinfo($n);
print sprintf ('%02X', $n), " which is ", $$ci{name}
, " matches\n";
$c++;
}
}
print "There are $c characters matching \"$re\".\n";
}
count_match('\s');
which gives:
09 which is <control> matches
0A which is <control> matches
0C which is <control> matches
0D which is <control> matches
20 which is SPACE matches
1680 which is OGHAM SPACE MARK matches
180E which is MONGOLIAN VOWEL SEPARATOR matches
2000 which is EN QUAD matches
2001 which is EM QUAD matches
2002 which is EN SPACE matches
2003 which is EM SPACE matches
2004 which is THREE-PER-EM SPACE matches
2005 which is FOUR-PER-EM SPACE matches
2006 which is SIX-PER-EM SPACE matches
2007 which is FIGURE SPACE matches
2008 which is PUNCTUATION SPACE matches
2009 which is THIN SPACE matches
200A which is HAIR SPACE matches
2028 which is LINE SEPARATOR matches
2029 which is PARAGRAPH SEPARATOR matches
202F which is NARROW NO-BREAK SPACE matches
205F which is MEDIUM MATHEMATICAL SPACE matches
3000 which is IDEOGRAPHIC SPACE matches
There are 23 characters matching "\s".
------------------------------
Date: Sat, 15 Mar 2008 22:27:05 -0700
From: "Steve K." <savagebeaste@yahoo.com>
Subject: Re: help with a regex
Message-Id: <643pdcF297i3nU1@mid.individual.net>
Uri Guttman wrote:
>>>>>> "d" == donebrowsers <donebrowsers@yahoo.com> writes:
>
> d> While that works and I appreciate it, I was just using the []s as
> a d> placeholder. I'm actually using PHP's <a
> href="http://us3.php.net/ d>
> manual/en/function.preg-match.php">preg_match()</a> function which
> d> uses PERL style regular expressions. I submitted it to this group
> d> because PERL programmers tend to be better with regular
> expressions d> than anyone else.
>
> it is Perl, never PERL. preg is NOT perl, nor is it compatible with
> perl. that is why we use Perl and not php. the answer you got was
> valid perl and that will likely be all you will get here.
1) What right do you have to speak for everyone? You should of said "and
that will likely be all you will get from me" as there are plenty of
people who actually offer help without the attitude people like your
self feel they must attach. You may not like PHP, but it has a place,
just as Perl does.
2) Yes we all know it's Perl. The world will cease to rotate properly on
it's axis and we will die well in advance of 2012 (right...) if someone
says PERL... one could always leave a friendly little note about it if
it really bothers you that much rather than the rude fucktardery your
types like to share.
------------------------------
Date: Sat, 15 Mar 2008 17:14:11 -0800
From: June Lee <iiuu66@yahoo.com>
Subject: HTML parsing
Message-Id: <23tot3pvjdm8p0gu8qbldlisl8b08a4d30@4ax.com>
any good way to extract the data?
I want to parse the following HTML page and extract TV listing data
using VC++
http://tvlistings.zap2it.com/tvlistings/ZCGrid.do
is easy for VC++ to call PERL script and do some regular expression?
since the HTML page is not XML well formed, I cannot use a XML parser
right?
any other good ways to extract HTML page data?
------------------------------
Date: Sun, 16 Mar 2008 00:35:48 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: HTML parsing
Message-Id: <o8qot3p97l46o9tqg3fd86pmqieorb409d@4ax.com>
June Lee <iiuu66@yahoo.com> wrote:
>any good way to extract the data?
> I want to parse the following HTML page
As has been mentioned many, many times in this NG: if you want to parse HTML
then use an HTML parser.
For further details please Read The Fine Manual: perldoc -q HTML
" How do I remove HTML from a string?"
While it doesn't address your question directly there is really no big
difference between extracting the text (= 'removing HTML') and extracting
specific other pieces of information.
>and extract TV listing data
>using VC++
Ahemmmm, are you sure you are asking in the right NG? This NG is about Perl.
>is easy for VC++ to call PERL script and do some regular expression?
Are you asking? Well, Perl (Perl is not an acronym but a name proper) is
certainly good at processing text and Perl's regular expression language is
very expressive. However this is rather irrelevant for parsing HTML because
HTML is not a regular language in the first place. Only a masochist would
try to parse HTML using REs.
>since the HTML page is not XML well formed, I cannot use a XML parser
>right?
Why would you want to use an XML parser on HTML source data? Oh, right, you
are also asking VC++ questions in a Perl NG.
>any other good ways to extract HTML page data?
Use one of the existing HTML parsers.
jue
------------------------------
Date: Sun, 16 Mar 2008 04:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Mar 16 2008
Message-Id: <Jxt3qH.K0J@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-MetaSyntactic-nethack-v1.0.1
http://search.cpan.org/~elliotjs/Acme-MetaSyntactic-nethack-v1.0.1/
The largest time waster in the world of *nix.
----
Acme-MetaSyntactic-vim-v1.0.1
http://search.cpan.org/~elliotjs/Acme-MetaSyntactic-vim-v1.0.1/
The Vim theme
----
Authen-TacacsPlus-0.19
http://search.cpan.org/~mikem/Authen-TacacsPlus-0.19/
Perl extension for authentication using tacacs+ server
----
CPAN-Faker-0.002
http://search.cpan.org/~rjbs/CPAN-Faker-0.002/
build a bogus CPAN instance for testing
----
DJabberd-Plugin-Ping-0.46
http://search.cpan.org/~misc/DJabberd-Plugin-Ping-0.46/
Add support for "XEP 0199, Xmpp Ping" to DJabberd.
----
DateTime-Format-Flexible-0.04
http://search.cpan.org/~thinc/DateTime-Format-Flexible-0.04/
DateTime::Format::Flexible - Flexibly parse strings and turn them into DateTime objects.
----
DateTime-Format-Natural-0.69
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.69/
Create machine readable date/time with natural parsing logic
----
Devel-TakeHashArgs-0.001
http://search.cpan.org/~zoffix/Devel-TakeHashArgs-0.001/
make a hash from @_ and set defaults in subs
----
Form-Processor-Model-DBIC-0.02
http://search.cpan.org/~gshank/Form-Processor-Model-DBIC-0.02/
Model class for Form Processor using DBIx::Class
----
Google-Adwords-v1.8.0
http://search.cpan.org/~rohan/Google-Adwords-v1.8.0/
an interface which abstracts the Google Adwords SOAP API
----
Gtk2-1.181
http://search.cpan.org/~tsch/Gtk2-1.181/
Perl interface to the 2.x series of the Gimp Toolkit library
----
Gtk2-MozEmbed-0.07
http://search.cpan.org/~tsch/Gtk2-MozEmbed-0.07/
Perl interface to the Mozilla embedding widget
----
HTML-CalendarMonth-1.19
http://search.cpan.org/~msisk/HTML-CalendarMonth-1.19/
Perl extension for generating and manipulating HTML calendar months
----
IO-Moose-0.02
http://search.cpan.org/~dexter/IO-Moose-0.02/
----
Lingua-PT-PLNbase-0.20
http://search.cpan.org/~ambs/Lingua-PT-PLNbase-0.20/
Perl extension for NLP of the Portuguese
----
MIME-Charset-1.001
http://search.cpan.org/~nezumi/MIME-Charset-1.001/
Charset Informations for MIME (MIME ??????????????)
----
MIME-EncWords-1.004
http://search.cpan.org/~nezumi/MIME-EncWords-1.004/
deal with RFC 2047 encoded words (improved)
----
Math-GMPf-0.26
http://search.cpan.org/~sisyphus/Math-GMPf-0.26/
perl interface to the GMP library's floating point (mpf) functions.
----
Moose-0.40
http://search.cpan.org/~stevan/Moose-0.40/
A postmodern object system for Perl 5
----
MooseX-Emulate-Class-Accessor-Fast-0.0001
http://search.cpan.org/~groditi/MooseX-Emulate-Class-Accessor-Fast-0.0001/
Emulate Class::Accessor::Fast behavior using Moose attributes
----
MooseX-Emulate-Class-Accessor-Fast-0.00100
http://search.cpan.org/~groditi/MooseX-Emulate-Class-Accessor-Fast-0.00100/
Emulate Class::Accessor::Fast behavior using Moose attributes
----
NET-Sieve-0.01
http://search.cpan.org/~yvesago/NET-Sieve-0.01/
Implementation of managesieve protocol to manage sieve scripts
----
Net-Address-IP-Local-v0.1
http://search.cpan.org/~jmehnle/Net-Address-IP-Local-v0.1/
A class for discovering the local system's IP address
----
RDF-Trine-0.105_01
http://search.cpan.org/~gwilliams/RDF-Trine-0.105_01/
An RDF Framework for Perl.
----
Task-Perl-Critic-IncludingOptionalDependencies-v1.002
http://search.cpan.org/~elliotjs/Task-Perl-Critic-IncludingOptionalDependencies-v1.002/
Install everything Perl::Critic plus its optional dependencies.
----
Task-Perl-Critic-v1.004
http://search.cpan.org/~elliotjs/Task-Perl-Critic-v1.004/
Install everything Perl::Critic.
----
Term-Title-0.02
http://search.cpan.org/~dagolden/Term-Title-0.02/
Portable API to set the terminal titlebar
----
Test-Aggregate-0.11
http://search.cpan.org/~ovid/Test-Aggregate-0.11/
Aggregate *.t tests to make them run faster.
----
Text-RewriteRules-0.11
http://search.cpan.org/~ambs/Text-RewriteRules-0.11/
A system to rewrite text using regexp-based rules
----
Text-vCard-2.02
http://search.cpan.org/~llap/Text-vCard-2.02/
a package to edit and create a single vCard (RFC 2426)
----
WWW-PasteCSSStandardsOrg-Create-0.002
http://search.cpan.org/~zoffix/WWW-PasteCSSStandardsOrg-Create-0.002/
create new pastes on http://paste.css-standards.org website
----
WWW-PhpfiCom-Create-0.001
http://search.cpan.org/~zoffix/WWW-PhpfiCom-Create-0.001/
create new pastes on http://phpfi.com pastebin site
----
WWW-Proxy4FreeCom-0.001
http://search.cpan.org/~zoffix/WWW-Proxy4FreeCom-0.001/
fetch proxy list from http://proxy4free.com/
----
WWW-ProxyChecker-0.001
http://search.cpan.org/~zoffix/WWW-ProxyChecker-0.001/
check whether or not proxy servers are alive
----
WWW-Search-Ask-1.006
http://search.cpan.org/~mthurn/WWW-Search-Ask-1.006/
class for searching www.search.com
----
WWW-YahooJapan-KanaAddress-0.1.1
http://search.cpan.org/~hiratara/WWW-YahooJapan-KanaAddress-0.1.1/
translating the address in Japan into kana.
----
WWW-YahooJapan-KanaAddress-v0.1.0
http://search.cpan.org/~hiratara/WWW-YahooJapan-KanaAddress-v0.1.0/
translating the address in Japan into kana.
----
WebService-Kizasi-v0.02
http://search.cpan.org/~daiba/WebService-Kizasi-v0.02/
A Perl Interface for the Kizasi Web Services
----
pQuery-0.04
http://search.cpan.org/~ingy/pQuery-0.04/
Perl Port of jQuery.js
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 15 Mar 2008 23:08:43 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: Pattern extraction
Message-Id: <fridhc030es@news2.newsguy.com>
Abigail wrote:
> _
> Deepan - M.Sc(SE) - 03MW06 (deepan.17@gmail.com) wrote on VCCCV
> September
> MCMXCIII in
> <URL:news:ae96a569-192c-49f4-a009-adc2052c15fd@d4g2000prg.googlegroups.com>:
> "" I am having a string like below: ""
> "" $str="/a/b/c/"; (or) $str = "/a/b/c/d/";
> ""
> "" What i need is that i should always be able to extract "c" from
> the "" above strings. I should not use split. Only by using regular
> "" expressions i should be able to achieve this. Please help me to
> solve "" this.
>
>
> Easy piecy!
>
>
> $str = "/a/b/c/"; # Or "/a/b/c/d/".
> my $answer = substr $str, 5, 1;
>
> say $answer;
>
> #
> # Dummy regexp to satisfy the homework requirements.
> #
> "" =~ /nananana/;
"say" ?
Can't call method "say" without a package or object reference
I am curious where this "say" came from?
$ perldoc say
No documentation found for "say".
$ perldoc -f say
No documentation for perl function `say' found
$ perldoc -q say
No documentation for perl FAQ keyword `say' found
Thanks.
--
szr
------------------------------
Date: Sun, 16 Mar 2008 06:28:57 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Pattern extraction
Message-Id: <J63Dj.108944$C61.38302@edtnps89>
szr wrote:
> Abigail wrote:
>> _
>> Easy piecy!
>>
>> $str = "/a/b/c/"; # Or "/a/b/c/d/".
>> my $answer = substr $str, 5, 1;
>>
>> say $answer;
>
> "say" ?
>
> Can't call method "say" without a package or object reference
>
>
> I am curious where this "say" came from?
>
>
> $ perldoc say
> No documentation found for "say".
>
> $ perldoc -f say
> No documentation for perl function `say' found
>
> $ perldoc -q say
> No documentation for perl FAQ keyword `say' found
say() is a new feature of Perl version 5.10 so you won't see it until
you upgrade.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Sun, 16 Mar 2008 03:57:32 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: regular expression with split goes wrong ?
Message-Id: <fri5rc$9l4$1@ml.accsnet.ne.jp>
On Tue, 11 Mar 2008 21:46:38 +0000, Abigail wrote:
> If *both* the pattern *and* the subject (the string matched against) are
> not in UTF-8, then, and only then, does \D equal [^0-9].
>
> However, if either of them is in UTF-8 format (which does not
> necessarely mean they contain a non-ASCII character), then \D excludes a
> lot more than just the digits 0 to 9.
>
> $ perl -wE 'chr =~ /[^0-9]/ or $c ++ for 0x00 .. 0xD7FF; say $c' 10
> $ perl -wE 'chr =~ /\D/ or $c ++ for 0x00 .. 0xD7FF; say $c' 220
You need to use (0x00 .. 0xD7FF, 0xE000 .. 0xFDCF, 0xFDF0.. 0xFFFD) here,
otherwise you miss 10 characters ("FULLWIDTH DIGIT X" in Unicode-speak).
The following gives 230 rather than 220 for the count:
#!/usr/bin/perl
use warnings;
use strict;
use Unicode::UCD 'charinfo';
sub count_match
{
my ($re)=@_;
my $c;
for my $n (0x00 .. 0xD7FF, 0xE000 .. 0xFDCF, 0xFDF0.. 0xFFFD) {
if (chr($n) =~ /$re/) {
my $ci = charinfo($n);
print sprintf ('%02X', $n), " which is ", $$ci{name}
, " matches\n";
$c++;
}
}
print "There are $c characters matching \"$re\".\n";
}
count_match('\d');
However, I got the above list of valid Unicode numbers here by trial and
error (running with 0x00..0xFFFF and seeing where Perl complained about
"Unicode character xxx is illegal") so there might be something I've
missed.
------------------------------
Date: Sat, 15 Mar 2008 21:08:01 -0800
From: "Robbie Hatley" <lonewolf@well.com>
Subject: Variables interpolated in character classes?
Message-Id: <YdudnYodkIB0AUHanZ2dnUVZ_tCrnZ2d@giganews.com>
I just wrote a Perl program to linkify text files with http URLs,
by generating an html file with the same content, but with the
URLs imbeded in a and p elements. Here's an edited-for-brevity
version:
# (snip code here for printing opening lines of HTML file)
while (<>)
{
# regex for recognizing URLs:
my $Regex = qr{(s?https?://[[:alnum:];/?:@=&#%$_.+!*'(),-]+)};
# wrap URLs in "a" and "p" elements, and put them on their own lines:
s{$Regex}{\n<p><a href="\1">\1</a></p>\n}g;
# Print the edited line:
print ($_);
}
# (snip code here for printing closing lines of HTML file)
To my surprise, I was getting error messages like this:
illegal [] range error i-b in "cgi-bin"
Huh??? There's no "cgi-bin" in the regex!!!
Then I realized, the regex contains "$_", which was embedding
the entire line of text to be searched inside the regex!
I had thought that character classes removed the special
meanings of all characters, with the exception of:
^ (inverts class; but only when first char.)
- (character range; but only if not first or last char.)
\ (for escaping ^ and -)
I got the program to work by replacing "$_" with "\$_",
and by moving the declaration of $Regex to top of program
to prevent having to recompile it every iteration.
But I'm still puzzled as to why I have escape the $.
Don't character classes prevent variable interpolation?
--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
www dott well dott com slant user slant lonewolf slant
------------------------------
Date: Sun, 16 Mar 2008 05:18:29 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Variables interpolated in character classes?
Message-Id: <F42Dj.108942$C61.104620@edtnps89>
Robbie Hatley wrote:
> I just wrote a Perl program to linkify text files with http URLs,
> by generating an html file with the same content, but with the
> URLs imbeded in a and p elements. Here's an edited-for-brevity
> version:
>
> # (snip code here for printing opening lines of HTML file)
> while (<>)
> {
> # regex for recognizing URLs:
> my $Regex = qr{(s?https?://[[:alnum:];/?:@=&#%$_.+!*'(),-]+)};
>
> # wrap URLs in "a" and "p" elements, and put them on their own lines:
> s{$Regex}{\n<p><a href="\1">\1</a></p>\n}g;
>
> # Print the edited line:
> print ($_);
> }
> # (snip code here for printing closing lines of HTML file)
>
>
> To my surprise, I was getting error messages like this:
>
> illegal [] range error i-b in "cgi-bin"
>
> Huh??? There's no "cgi-bin" in the regex!!!
>
> Then I realized, the regex contains "$_", which was embedding
> the entire line of text to be searched inside the regex!
>
> I had thought that character classes removed the special
> meanings of all characters, with the exception of:
> ^ (inverts class; but only when first char.)
> - (character range; but only if not first or last char.)
> \ (for escaping ^ and -)
>
> I got the program to work by replacing "$_" with "\$_",
> and by moving the declaration of $Regex to top of program
> to prevent having to recompile it every iteration.
> But I'm still puzzled as to why I have escape the $.
> Don't character classes prevent variable interpolation?
Read the "Gory details of parsing quoted constructs" section of perlop.pod:
perldoc perlop
The gist of it is that qr//, m// and s/// are first interpolated as
double quoted strings before they are processed by the regular
expression engine. For example:
$ perl -le'$x = "abc"; @y = "D".."F"; $z = qr/[-($x)~{@y}^]/; print $z'
(?-xism:[-(abc)~{D E F}^])
You can avoid interpolation by using single quote delimiters instead:
my $Regex = qr'(s?https?://[[:alnum:];/?:@=&#%$_.+!*\'(),-]+)';
Also the back-references \1, \2, etc. should only be used *inside* a
regular expression, but not in a character class. Outside of a regular
expression you should use $1, $2, etc. instead. So:
s{$Regex}{\n<p><a href="\1">\1</a></p>\n}g;
Should be:
s{$Regex}{\n<p><a href="$1">$1</a></p>\n}g;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
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:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#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 1365
***************************************