[27913] in Perl-Users-Digest
Perl-Users Digest, Issue: 9277 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 10 03:05:42 2006
Date: Sat, 10 Jun 2006 00:05:05 -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 Sat, 10 Jun 2006 Volume: 10 Number: 9277
Today's topics:
=?utf-8?B?Z29vZ2xlLmNvbeW3suaBouWkjeato+W4uA==?= <njhotel@gmail.com>
Re: Binding array to pattern <tadmc@augustmail.com>
Re: Binding array to pattern <tadmc@augustmail.com>
Bug of <= operator? <haikun@gmail.com>
Re: Bug of <= operator? <David.Squire@no.spam.from.here.au>
Re: Bug of <= operator? <someone@example.com>
Re: Bug of <= operator? <David.Squire@no.spam.from.here.au>
Re: Bug of <= operator? <haikun@gmail.com>
Re: Bug of <= operator? <David.Squire@no.spam.from.here.au>
Re: Bug of <= operator? <jgibson@mail.arc.nasa.gov>
calling AWK from perl question wazzu62@hotmail.com
Re: calling AWK from perl question <someone@example.com>
Re: calling AWK from perl question <glennj@ncf.ca>
Re: CGI for collecting phone numbers <tadmc@augustmail.com>
Follow Up [was Re: Multiple Line output using Win32::Pr <goodcall1@hotmail.dot.com>
GIFS not working properly in JavaScript PopUps <vcharles2k@gmail.com>
Re: Merging potentially undefined hashes <tadmc@augustmail.com>
new CPAN modules on Sat Jun 10 2006 (Randal Schwartz)
Re: regular expression again <tadmc@augustmail.com>
Re: regular expression again <xicheng@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Jun 2006 23:23:21 -0700
From: "=?utf-8?B?6YeR5Yia?=" <njhotel@gmail.com>
Subject: =?utf-8?B?Z29vZ2xlLmNvbeW3suaBouWkjeato+W4uA==?=
Message-Id: <1149920601.319305.167570@h76g2000cwa.googlegroups.com>
Z29vZ2xlLmNvbeW3suaBouWkjeato+W4uO+8jOi/nue7reWNgeWkmuWkqeeahOS4jeeos+WumuW3
suaIkOS4uui/h+WOu++8jOWkp+WutuWPr+S7peivleS4gOS4i+aYr+S4jeaYr+OAggoK5o2u572R
5LiK5paH56ug5LuL57uN77yMZ29vZ2xlLmNuCuWKoOS6huaVj+aEn+aWh+Wtl+i/h+a7pOWKn+iD
ve+8jOiAjGdvb2dsZS5jb23msqHmnInov4fmu6TmloflrZfvvIzmiYDku6Vnb29nbGUuY29t55qE
5pCc57Si57uT5p6c5q+UZ29vZ2xlLmNu5Liw5a+M5LiA5Lqb44CC6L+Y5piv55SoZ29vZ2xlLmNv
beWQpy4KCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tCuWNl+S6rOaXhea4uOWNl+S6rOmFkuW6l+WNl+S6rOWuvumm
huS8mOaDoOS7t+agvOWPiumihOiuogoKaHR0cDovL2dyb3Vwcy5nb29nbGUuY29tL2dyb3VwL25q
aG90ZWw/aGw9emgtQ04KCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCg==
------------------------------
Date: Fri, 9 Jun 2006 16:46:15 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Binding array to pattern
Message-Id: <slrne8jr17.6lc.tadmc@magna.augustmail.com>
Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid> wrote:
> I need a term in a boolean expression for a match anywhere in the
> array.
> if (/abuse/ or $scalarContacts =~ /abuse/);
if grep /abuse/, $_, @{$host_info{$host}{Email}{$_}};
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 9 Jun 2006 17:21:25 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Binding array to pattern
Message-Id: <slrne8jt35.6lc.tadmc@magna.augustmail.com>
Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid> wrote:
> In <slrne8hgee.3rt.tadmc@magna.augustmail.com>, on 06/08/2006
> at 07:33 PM, Tad McClellan <tadmc@augustmail.com> said:
>
>>That makes no sense.
[ The "that" was snipped, it was:
I'd like to bind an array to a pattern.
]
> To you. Others had no trouble understanding it.
Neither you nor any of the others understood "bind an array to a pattern".
The rest of your OP below here, and the followups I've seen so far,
where all with binding a string to a pattern (a string (supposedly)
made up of strings taken from some array).
>>Why would you like to bind an array to a pattern?
>
> Because I want all of the matches on all of the strings in the array.
My suggestion would do that for you.
>>Do you instead want to apply a pattern match to each _element_ of an
>>array?
>
> That would be obvious if you looked at the code.
It was not obvious if you _understood_ the code.
I looked at it and saw that
@array = ('a', 'b');
print "true" if "@array" =~ /a b/g;
would fail to do the Right Thing.
> Do you know how
> interpolation works inside quotes?
Better than you do, apparently.
>>If so, then use foreach or grep.
>
> That would complicate the logic in this case.
No it wouldn't.
> Scan an array for a pattern as part of a larger boolean expression.
Use grep(), just like I suggested then.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 Jun 2006 15:27:52 -0700
From: "Haikun" <haikun@gmail.com>
Subject: Bug of <= operator?
Message-Id: <1149892072.679366.134940@h76g2000cwa.googlegroups.com>
Dear folks,
I'm not sure if this is a bug of the less than "<=" operator, but the
following piece of code looks like a mystery to me.
==== code snippet start =============
#!/usr/bin/perl -w
use strict;
use warnings;
my $start = 0.001;
my $step = 0.001;
for( my $i=$start; $i <= 0.009; $i+=$step){
print "$i\n";
}
==== code snippet end ==============
The output is
0.001
0.002
0.003
0.004
0.005
0.006
0.007
0.008
and 0.009 is missing from the output. If I change "<=" in the for
clause to "le", the output becomes expected.
0.001
0.002
0.003
0.004
0.005
0.006
0.007
0.008
0.009
I know this looks impossible. But if you take a try you'll see it. I'm
using the latest perl 5.8.8 on Windows.
Thanks,
Haikun
------------------------------
Date: Fri, 09 Jun 2006 23:33:10 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Bug of <= operator?
Message-Id: <e6csv6$5nu$1@news.ox.ac.uk>
Haikun wrote:
> Dear folks,
>
> I'm not sure if this is a bug of the less than "<=" operator, but the
> following piece of code looks like a mystery to me.
Time to read the FAQ on the (necessarily approximate) binary floating
point representation of decimal numbers. In Perl or any other language
compiled to run on hardware based on binary representations.
perldoc -q decimal
Regards,
DS
>
> ==== code snippet start =============
> #!/usr/bin/perl -w
>
> use strict;
> use warnings;
>
> my $start = 0.001;
> my $step = 0.001;
>
> for( my $i=$start; $i <= 0.009; $i+=$step){
> print "$i\n";
> }
> ==== code snippet end ==============
>
> The output is
> 0.001
> 0.002
> 0.003
> 0.004
> 0.005
> 0.006
> 0.007
> 0.008
>
> and 0.009 is missing from the output. If I change "<=" in the for
> clause to "le", the output becomes expected.
> 0.001
> 0.002
> 0.003
> 0.004
> 0.005
> 0.006
> 0.007
> 0.008
> 0.009
>
> I know this looks impossible. But if you take a try you'll see it. I'm
> using the latest perl 5.8.8 on Windows.
>
> Thanks,
> Haikun
>
------------------------------
Date: Fri, 09 Jun 2006 22:37:10 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Bug of <= operator?
Message-Id: <qKmig.32969$S61.30304@edtnps90>
Haikun wrote:
>
> I'm not sure if this is a bug of the less than "<=" operator, but the
> following piece of code looks like a mystery to me.
No, this is not a bug, that is the way that floating point numbers work on
binary computers.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 09 Jun 2006 23:38:38 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Bug of <= operator?
Message-Id: <e6ct9e$5oh$1@news.ox.ac.uk>
David Squire wrote:
> Haikun wrote:
>> Dear folks,
>>
>> I'm not sure if this is a bug of the less than "<=" operator, but the
>> following piece of code looks like a mystery to me.
>
> Time to read the FAQ on the (necessarily approximate) binary floating
> point representation of decimal numbers. In Perl or any other language
> compiled to run on hardware based on binary representations.
>
> perldoc -q decimal
>
>>
>> ==== code snippet start =============
>> #!/usr/bin/perl -w
>>
>> use strict;
>> use warnings;
>>
>> my $start = 0.001;
>> my $step = 0.001;
>>
>> for( my $i=$start; $i <= 0.009; $i+=$step){
>> print "$i\n";
>> }
>> ==== code snippet end ==============
>>
Perhaps this will help to convince:
----
#!/usr/bin/perl
use strict;
use warnings;
my $start = 0.001;
my $step = 0.001;
my $eps = 1e-10;
my $count = 0;
for( my $i=$start; $i <= 0.009 + $eps; $i+=$step){
print "$i\n";
$count++;
print "\$count = $count\n";
}
----
Output:
0.001
$count = 1
0.002
$count = 2
0.003
$count = 3
0.004
$count = 4
0.005
$count = 5
0.006
$count = 6
0.007
$count = 7
0.008
$count = 8
0.009
$count = 9
Regards,
DS
------------------------------
Date: 9 Jun 2006 15:59:48 -0700
From: "Haikun" <haikun@gmail.com>
Subject: Re: Bug of <= operator?
Message-Id: <1149893987.920705.62260@j55g2000cwa.googlegroups.com>
I see. Thanks for the clarification. But then my (possibly irrelevant)
questions is, why would "<=" and "le" exhibit different behavior?
I know "le" is also used to do string comparison. But in this case, if
I code
for( my $i=$start; $i le 9e-03; $i+=$step){
print "$i\n";
}
The output is still correct. I have never observed "le" to fail in this
matter.
Thanks,
Haikun
David Squire wrote:
> David Squire wrote:
> > Haikun wrote:
> >> Dear folks,
> >>
> >> I'm not sure if this is a bug of the less than "<=" operator, but the
> >> following piece of code looks like a mystery to me.
> >
> > Time to read the FAQ on the (necessarily approximate) binary floating
> > point representation of decimal numbers. In Perl or any other language
> > compiled to run on hardware based on binary representations.
> >
> > perldoc -q decimal
> >
> >>
> >> ==== code snippet start =============
> >> #!/usr/bin/perl -w
> >>
> >> use strict;
> >> use warnings;
> >>
> >> my $start = 0.001;
> >> my $step = 0.001;
> >>
> >> for( my $i=$start; $i <= 0.009; $i+=$step){
> >> print "$i\n";
> >> }
> >> ==== code snippet end ==============
> >>
>
> Perhaps this will help to convince:
>
> ----
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $start = 0.001;
> my $step = 0.001;
> my $eps = 1e-10;
>
> my $count = 0;
> for( my $i=$start; $i <= 0.009 + $eps; $i+=$step){
> print "$i\n";
> $count++;
> print "\$count = $count\n";
> }
>
> ----
>
> Output:
>
> 0.001
> $count = 1
> 0.002
> $count = 2
> 0.003
> $count = 3
> 0.004
> $count = 4
> 0.005
> $count = 5
> 0.006
> $count = 6
> 0.007
> $count = 7
> 0.008
> $count = 8
> 0.009
> $count = 9
>
>
> Regards,
>
> DS
------------------------------
Date: Sat, 10 Jun 2006 00:10:30 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Bug of <= operator?
Message-Id: <e6cv57$6gd$1@news.ox.ac.uk>
Haikun wrote:
[top-posting corrected. Please don't do that. See the posting guidelines
for this group]
>
> David Squire wrote:
>> David Squire wrote:
>>> Haikun wrote:
>>>> Dear folks,
>>>>
>>>> I'm not sure if this is a bug of the less than "<=" operator, but the
>>>> following piece of code looks like a mystery to me.
>>> Time to read the FAQ on the (necessarily approximate) binary floating
>>> point representation of decimal numbers. In Perl or any other language
>>> compiled to run on hardware based on binary representations.
>>>
>>> perldoc -q decimal
>>>
>>>> ==== code snippet start =============
>>>> #!/usr/bin/perl -w
>>>>
>>>> use strict;
>>>> use warnings;
>>>>
>>>> my $start = 0.001;
>>>> my $step = 0.001;
>>>>
>>>> for( my $i=$start; $i <= 0.009; $i+=$step){
>>>> print "$i\n";
>>>> }
>>>> ==== code snippet end ==============
>>>>
>> Perhaps this will help to convince:
>>
>> ----
>>
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>>
>> my $start = 0.001;
>> my $step = 0.001;
>> my $eps = 1e-10;
>>
>> my $count = 0;
>> for( my $i=$start; $i <= 0.009 + $eps; $i+=$step){
>> print "$i\n";
>> $count++;
>> print "\$count = $count\n";
>> }
>>
> I see. Thanks for the clarification. But then my (possibly irrelevant)
> questions is, why would "<=" and "le" exhibit different behavior?
>
> I know "le" is also used to do string comparison. But in this case, if
> I code
>
> for( my $i=$start; $i le 9e-03; $i+=$step){
> print "$i\n";
> }
>
> The output is still correct. I have never observed "le" to fail in this
> matter.
Here's one that does:
----
#!/usr/bin/perl
use strict;
use warnings;
for(my $i = 0; $i le 10; $i++){
print "$i\n";
}
----
Output:
----
0
1
----
Think about the string ordering of the numbers of your example. It works
by coincidence.
DS
------------------------------
Date: Fri, 09 Jun 2006 16:59:24 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Bug of <= operator?
Message-Id: <090620061659244274%jgibson@mail.arc.nasa.gov>
In article <e6cv57$6gd$1@news.ox.ac.uk>, David Squire
<David.Squire@no.spam.from.here.au> wrote:
> Haikun wrote:
> >>>> ==== code snippet start =============
> >>>> #!/usr/bin/perl -w
> >>>>
> >>>> use strict;
> >>>> use warnings;
> >>>>
> >>>> my $start = 0.001;
> >>>> my $step = 0.001;
> >>>>
> >>>> for( my $i=$start; $i <= 0.009; $i+=$step){
> >>>> print "$i\n";
> >>>> }
> >>>> ==== code snippet end ==============
> > The output is still correct. I have never observed "le" to fail in this
> > matter.
>
> Here's one that does:
>
> ----
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> for(my $i = 0; $i le 10; $i++){
> print "$i\n";
> }
>
> ----
>
> Output:
>
> ----
>
> 0
> 1
>
> ----
>
> Think about the string ordering of the numbers of your example. It works
> by coincidence.
But keep in mind that in being stringified, $i is rounded, which is the
real reason the original program works with le instead of <=:
#!/usr/local/bin/perl
#
use strict;
use warnings;
my $start = 0.001;
my $step = 0.001;
for( my $i = $start; $i le 0.011; $i += $step ) {
my $s = "" . $i;
printf "%5s <- %.20f\n", $s, $i;
}
0.001 <- 0.00100000000000000002
0.002 <- 0.00200000000000000004
0.003 <- 0.00300000000000000006
0.004 <- 0.00400000000000000008
0.005 <- 0.00500000000000000010
0.006 <- 0.00600000000000000012
0.007 <- 0.00700000000000000015
0.008 <- 0.00800000000000000017
0.009 <- 0.00900000000000000105
0.01 <- 0.01000000000000000194
0.011 <- 0.01100000000000000283
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 9 Jun 2006 16:13:10 -0700
From: wazzu62@hotmail.com
Subject: calling AWK from perl question
Message-Id: <1149894790.127612.42980@h76g2000cwa.googlegroups.com>
I am a perl newbie and am trying to convert some shell scripts I have
written into perl as a learning excercise.
I have a bash script that has this line in it:
ksize=`du -sk /files/archive/$period/$day/*$site* | awk '{sum = sum +
$1} END {print sum}'`
If I imbed this in a perl script as such:
$ksize=`du -sk /files/archive/$dates[$cnt]/*$site* | awk '{sum = sum +
[$1]} END {print sum}'`;
It generates this error
awk: cmd. line:1: {sum = sum + []} END {print sum}
awk: cmd. line:1: ^ parse error
expr: syntax error
It seems to not like the $1 variable awk is using.
Anyone have any ideas how to get around this?
Thanks in advance.
wazzu
------------------------------
Date: Fri, 09 Jun 2006 23:25:26 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: calling AWK from perl question
Message-Id: <Grnig.33115$S61.4546@edtnps90>
wazzu62@hotmail.com wrote:
> I am a perl newbie and am trying to convert some shell scripts I have
> written into perl as a learning excercise.
>
> I have a bash script that has this line in it:
>
> ksize=`du -sk /files/archive/$period/$day/*$site* | awk '{sum = sum +
> $1} END {print sum}'`
No need to use AWK:
my $ksize;
for ( `du -sk /files/archive/$period/$day/*$site*` ) {
$ksize += ( split )[ 0 ];
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: 9 Jun 2006 23:50:46 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: calling AWK from perl question
Message-Id: <slrne8k2am.hg5.glennj@smeagol.ncf.ca>
At 2006-06-09 07:13PM, wazzu62@hotmail.com <wazzu62@hotmail.com> wrote:
> $ksize=`du -sk /files/archive/$dates[$cnt]/*$site* | awk '{sum = sum +
> [$1]} END {print sum}'`;
>
> It generates this error
>
> awk: cmd. line:1: {sum = sum + []} END {print sum}
> awk: cmd. line:1: ^ parse error
> expr: syntax error
Why are you enclosing '$1' in brackets? What do you think that does?
Your answer is that perl substitutes variables inside backticks. Inside
backticks, single quotes have no special meaning. You need to protect
the dollar sign:
$ksize=`du -sk /files/archive/$dates[$cnt]/*$site* | awk '{sum = sum + \$1} END {print sum}'`;
or
my $awkscript = '{sum = sum + $1} END {print sum}';
my $ksize=`du -sk /files/archive/$dates[$cnt]/*$site* | awk '$awkscript'`;
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: Fri, 9 Jun 2006 17:34:03 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: CGI for collecting phone numbers
Message-Id: <slrne8jtqr.6lc.tadmc@magna.augustmail.com>
ferreira@unm.edu <ferreira@unm.edu> wrote:
> This is what I have:
> #!/usr/bin/perl
> use CGI::Carp qw(fatalsToBrowser);
> my $file = '/users/web/king/web/sms.txt';
> open (FILE, ">>" . $file) or die "cannot open file for appending: $!";
> flock (FILE, 2) or die "cannot lock file exclusively: $!";
> print "Content-type: text/html\n\n";
> print FILE $phone . "\n";
> close (FILE) or die "cannot close file: $!";
You have never given $phone a value!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 10 Jun 2006 06:02:54 GMT
From: "Jack D" <goodcall1@hotmail.dot.com>
Subject: Follow Up [was Re: Multiple Line output using Win32::Printer]
Message-Id: <igtig.33262$S61.1556@edtnps90>
"Jack D" <goodcall1@hotmail.dot.com> wrote in message
news:zmShg.25618$S61.24326@edtnps90...
> I'm trying to output mutilple lines to a printer using Win32::Printer. I
> have only suceeded in printing one line so far. Does anyone know how force
> it to print multiple lines? The output is shows rectangles in between each
> word.
>
> Sample code below
>
> use strict;
> use Win32::Printer;
> my @array = keys %ENV;
>
> printMultiple();
>
> sub printMultiple {
> my $dc = new Win32::Printer( papersize => A4,
> description => 'Test,
> unit => 'mm') or die "Failed to
> create printer object";
> if ($dc) {
> my $textToPrint = join("\r\n",@oldarray);
> my $font = $dc->Font('Times New Roman', 12);
> $dc->Font($font);
> $dc->Color(0, 0, 0);
> $dc->Write($textToPrint, 10, 10);
> $dc->Close;
> }
> }
> __END__
>
Just a follow up for any future Googlers.
After a direct e-mail to the Edgars Binans, the solution is to either write
in "draw mode", use Write2 or print the array element by element
incrementing the y value as you go. Working code below:
use Win32::Printer;
my @array = keys %ENV;
printAlpha();
sub printAlpha {
my $dc = new Win32::Printer(
papersize => A4,
description => 'Test Print',
unit => 'pt')
or die "Failed to create object";
if ($dc) {
my $font = $dc->Font('Times New Roman', 10);
$dc->Font($font);
$dc->Color(0, 0, 0);
my $v = 10;
foreach my $line (@array) {
$dc->Write($line, 10, $v);
$v+=10;
}
$dc->Close;
}
}
------------------------------
Date: 9 Jun 2006 23:34:18 -0700
From: "Charleees" <vcharles2k@gmail.com>
Subject: GIFS not working properly in JavaScript PopUps
Message-Id: <1149921258.060741.214000@y43g2000cwc.googlegroups.com>
Hi all,
I have a button and when i click tha button it redirects to another
page.....
I have also added a java script for the button that makes a popup..
the pop up is actually a DIV tag.. with a GIF image in it......
what actually should happen is ...
when i click the button ..the pop up should be visible with the
animated gif ..this should be visible till the processing is done and
the page is redirected....
popup here acts like a Processing bar...
The problem i have is ..
when i add this javascript... i could get the Gifs Animation...but the
button click is not called
SearchBtn.Attributes.Add("onclick","GetPosition('"+this.SearchBtn.ClientID+"');return
false");
if i do the following....
SearchBtn.Attributes.Add("onclick","GetPosition('"+this.SearchBtn.ClientID+"');return
true");
i could show the pop up till the processing is done and redirect but
the only problem is..... i could not have a proper animated gif image..
i have done the following in button click:
private void SearchBtn_Click(object sender, System.EventArgs e)
{
search.DoSearch();
Response.Redirect("searchResult.aspx);
}
how could i solve this problem... any alternate way..
its urgent..please help...
Thanks in Advance..
Sanjay.C
------------------------------
Date: Fri, 9 Jun 2006 17:44:58 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Merging potentially undefined hashes
Message-Id: <slrne8jufa.6lc.tadmc@magna.augustmail.com>
Derek Basch <dbasch@yahoo.com> wrote:
> I have several functions (getBillingDatabaseAttributes, etc...) that
> can either return a hash reference or undefined. They just return a DBI
> selectrow_hashref function such as:
>
> $hash_ref = $dbh->selectrow_hashref($statement);
Use the standard idiom for applying a default value:
$hash_ref = $dbh->selectrow_hashref($statement) || {};
> How can I merge these hashes and undefined values?
>
> If I do this:
>
> %hash1 = (%$hash2, %$hash3);
>
> I get a 'cant reference undefined value' error.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 10 Jun 2006 04:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Jun 10 2006
Message-Id: <J0Mnq7.23K1@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.
Exception-Class-DBI-0.93
http://search.cpan.org/~dwheeler/Exception-Class-DBI-0.93/
DBI Exception objects
----
Moose-Autobox-0.01
http://search.cpan.org/~stevan/Moose-Autobox-0.01/
Autoboxed for her pleasure
----
Email-Filter-Rules-1.1
http://search.cpan.org/~jbisbee/Email-Filter-Rules-1.1/
Simple Rules for Routing Mail with Email::Filter
----
DBD-mysql-3.0005
http://search.cpan.org/~capttofu/DBD-mysql-3.0005/
MySQL driver for the Perl5 Database Interface (DBI)
----
DBD-mysql-3.0005_1
http://search.cpan.org/~capttofu/DBD-mysql-3.0005_1/
MySQL driver for the Perl5 Database Interface (DBI)
----
Logger-Simple-2.0
http://search.cpan.org/~tstanley/Logger-Simple-2.0/
Implementation of the Simran-Log-Log and Simran-Error-Error modules
----
Net-FeedBurner-0.08
http://search.cpan.org/~sock/Net-FeedBurner-0.08/
The great new Net::FeedBurner!
----
DBIx-Class-0.06999_02
http://search.cpan.org/~mstrout/DBIx-Class-0.06999_02/
Extensible and flexible object <-> relational mapper.
----
Acme-PM-Dresden-0.10
http://search.cpan.org/~schwigon/Acme-PM-Dresden-0.10/
----
WWW-TWikiClient-0.10
http://search.cpan.org/~schwigon/WWW-TWikiClient-0.10/
WWW::Mechanize-based client to access a TWiki.
----
IPC-Lock-0.14
http://search.cpan.org/~earl/IPC-Lock-0.14/
simple and safe local/network locking
----
Net-FeedBurner-0.07
http://search.cpan.org/~sock/Net-FeedBurner-0.07/
The great new Net::FeedBurner!
----
Net-Bluetooth-0.32
http://search.cpan.org/~iguthrie/Net-Bluetooth-0.32/
Perl Bluetooth Interface
----
Task-Math-Symbolic-1.01
http://search.cpan.org/~smueller/Task-Math-Symbolic-1.01/
Math::Symbolic with lots of plugins
----
Task-App-Physics-ParticleMotion-1.01
http://search.cpan.org/~smueller/Task-App-Physics-ParticleMotion-1.01/
All modules required for the tk-motion application
----
Process-YAML-0.03
http://search.cpan.org/~smueller/Process-YAML-0.03/
The Process::Serializable role implemented by YAML
----
Math-Symbolic-Custom-LaTeXDumper-0.203
http://search.cpan.org/~smueller/Math-Symbolic-Custom-LaTeXDumper-0.203/
Math::Symbolic LaTeX output
----
WWW-YouTube-2006.0609
http://search.cpan.org/~ermeyers/WWW-YouTube-2006.0609/
YouTube Development Interface (YTDI)
----
Number-WithError-LaTeX-0.03
http://search.cpan.org/~smueller/Number-WithError-LaTeX-0.03/
LaTeX output for Number::WithError
----
Number-WithError-0.05
http://search.cpan.org/~smueller/Number-WithError-0.05/
Numbers with error propagation and scientific rounding
----
Apache-Session-Wrapper-0.29
http://search.cpan.org/~drolsky/Apache-Session-Wrapper-0.29/
A simple wrapper around Apache::Session
----
HTML-ReportWriter-1.4.0
http://search.cpan.org/~opiate/HTML-ReportWriter-1.4.0/
Simple OO interface to generate pageable, sortable HTML tabular reports
----
IO-Tty-1.05
http://search.cpan.org/~rgiersig/IO-Tty-1.05/
Low-level allocate a pseudo-Tty, import constants.
----
Bigtop-0.13
http://search.cpan.org/~philcrow/Bigtop-0.13/
A web application data language processor
----
OS390-IEBUtils-0.01
http://search.cpan.org/~pboin/OS390-IEBUtils-0.01/
IEBPTPCH and IEBUPDTE work-alikes.
----
EekBoek-0.60
http://search.cpan.org/~jv/EekBoek-0.60/
Bookkeeping software for small and medium-size businesses
----
Hardware-Vhdl-Lexer-0.06
http://search.cpan.org/~mykl/Hardware-Vhdl-Lexer-0.06/
Split VHDL code into lexical tokens
----
Search-Namazu-0.96
http://search.cpan.org/~knok/Search-Namazu-0.96/
Namazu library module for perl
----
Graph-0.75
http://search.cpan.org/~jhi/Graph-0.75/
graph data structures and algorithms
----
Net-GPSD-0.22
http://search.cpan.org/~mrdvt/Net-GPSD-0.22/
Provides a perl interface to the gpsd daemon.
----
MP3-Tag-0.9708
http://search.cpan.org/~ilyaz/MP3-Tag-0.9708/
Module for reading tags of MP3 audio files
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.
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: Fri, 9 Jun 2006 17:39:18 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regular expression again
Message-Id: <slrne8ju4m.6lc.tadmc@magna.augustmail.com>
Peter Janssens <peter@nowhere.com> wrote:
> Original question.
Did you read the entire other thread?
> I want to retrieve all occurences of a string "aa". So in the search string
> "aaaa", I have to find it three times (aa)aa, a(aa)a, aa(aa).
>
> How can I do that, using regular expressions in Perl?
The way that I showed in the original thread is one way.
If that way doesn't work for you, then tell use why not, and we
might be able to work around whatever the issue is...
> Suppose I want to search for aaa or aab in the string aaabaabaa.
The code I posted does that.
> Your help is appreciated.
If you say so.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 Jun 2006 16:54:18 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: regular expression again
Message-Id: <1149897258.936645.23200@y43g2000cwc.googlegroups.com>
Peter Janssens wrote:
> Hi,
>
> Original question.
> I want to retrieve all occurences of a string "aa". So in the search string
> "aaaa", I have to find it three times (aa)aa, a(aa)a, aa(aa).
>
> How can I do that, using regular expressions in Perl?
>
> The following solution (previous post) works fine but ...
> /(a(?=(a)))/g
>
> Suppose I want to search for aaa or aab in the string aaabaabaa.
>
> I thaught the following will do the job: a(?=a)[ab].
> But is doesn't.
>
> Also, if you try something like aa[ab] it will find the first instance (aaa)
> but
> not the second (aab) in aaabaabaa.
>
> Your help is appreciated.
you could extend John's way, say:
print for "aaabaabaa" =~ /(?=(aa[ab]))/g
or some more regex's ways, like:
"aaabaabaa" =~ /(aa[ab])(?{print $1})(?!)/;
Let me show you how the above regex works:
(aa[ab]): get a match, and save the string into $1,
(?{print $1}): immediately print the matched string in $1
(?!) : matching failed, so $1 forcefully becomes non-matched.
According to the regex engine(the traditional NFA) behind Perl, the
regex will try another possiblity from the next trying-point until it
finds a match or finally fails. (?!) is the key that guarentees the
regex fails,(so the above matching expression will never success) and
the result is that the regex traverses all possiblities of the matching
cases and prints them out..
BTW. this is NOT a recommended way to solve your problem, but a way to
know something more about the Perl regex. you might find more useful
and interesting information in the book "Mastering Regular
Expressions"(strongly recommended).
Good luck,
Xicheng
------------------------------
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 V10 Issue 9277
***************************************