[25845] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8080 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 15 03:05:21 2005

Date: Sun, 15 May 2005 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           Sun, 15 May 2005     Volume: 10 Number: 8080

Today's topics:
        Palm::PDB problem  <pdconetwofour_numbers_@yahoo.co.uk>
    Re: Perl generated navigation menu <spam@noreply.org>
        Regex not matching <Andrew@DeFaria.com>
    Re: Regex not matching <ignoramus4744@NOSPAM.4744.invalid>
    Re: Regex not matching <Andrew@DeFaria.com>
    Re: Regex not matching <Andrew@DeFaria.com>
    Re: Regex not matching <eighner@io.com>
    Re: Regex not matching <matternc@comcast.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 14 May 2005 16:08:53 GMT
From: p cooper <pdconetwofour_numbers_@yahoo.co.uk>
Subject: Palm::PDB problem 
Message-Id: <pophe.31948$G8.11940@text.news.blueyonder.co.uk>

back to this after a brief respite :
Im trying to get data from my Palm , eventually to MySQL

#!/usr/bin/perl -w
use Palm::PDB;
use Palm::Raw;
use Data::Dumper;
Palm::PDB::RegisterPDBHandlers("Palm::Raw", "");
my $pdb = new Palm::PDB();
$pdb->Load("LOGBOOK.pdb");
my $array_ref = $pdb->{"records"};
#print Dumper($array_ref);
foreach  $record ( @{ $array_ref})
{
#print $record;#$record is  hash: #print %{$record};
$rec= $record->{'data'};
print $rec;
print "\n";
}
prints a string that seems to be values for fields ??concatenated together 
Im stuck as to how to split the string. 

the Palm::PDB page on CPAN  also has reference to 'ParseRecord' but its not
clear to me how i cna use it in this setup  





------------------------------

Date: Sat, 14 May 2005 17:42:30 +0000
From: michael <spam@noreply.org>
Subject: Re: Perl generated navigation menu
Message-Id: <d656a3$rfd$00$1@news.t-online.com>

>    perldoc perlreftut
>    perldoc perlref
>    perldoc perllol
>    perldoc perldsc

Will read....

> I would now suggest a different "better" structure, a HoLoH:

Thanks!

> Show us the code you've already tried, and we will help you fix it.

Thanks, but I've got no code yet, as I'm trying to figure how to, but your
suggestions should have got me on the right track.

Michael

-- 
You will be awarded the Nobel Peace Prize... posthumously.


------------------------------

Date: Sun, 15 May 2005 03:37:23 GMT
From: Andrew DeFaria <Andrew@DeFaria.com>
Subject: Regex not matching
Message-Id: <Ttzhe.522$W51.4695@typhoon.sonic.net>

I thought I understood Perl regexs pretty well but this one confuses me. 
What am I doing wrong here?

#!/usr/bin/perl                                                                 

use 
strict;                                                                    
use 
warnings;                                                                  
                                                                                

$_ = "#if __LDBL_SIZE == 80 
block";                                            
                                                                                

if (/^#.*= (\d*)/) 
{                                                           
  print "Pattern matched \$1 = 
\"$1\"\n";                                      
} else 
{                                                                       
  print "Pattern did not 
match\n";                                             
}                                                                               

                                                                                

if (/^#.*(\d*)/) 
{                                                             
  print "Pattern matched \$1 = 
\"$1\"\n";                                      
} else 
{                                                                       
  print "Pattern did not 
match\n";                                             
}

Outputs:

Pattern matched $1 = 
"80"                                                     
Pattern matched $1 = ""

Why does the second pattern fail?!?
-- 
Experience is something you don't get until just after you need it.


------------------------------

Date: 15 May 2005 03:51:52 GMT
From: Ignoramus4744 <ignoramus4744@NOSPAM.4744.invalid>
Subject: Re: Regex not matching
Message-Id: <d66h0o$tj3$0@pita.alt.net>

On Sun, 15 May 2005 03:37:23 GMT, Andrew DeFaria <Andrew@DeFaria.com> wrote:
> I thought I understood Perl regexs pretty well but this one confuses me. 
> What am I doing wrong here?
>
> #!/usr/bin/perl                                                                 
>
> use 
> strict;                                                                    
> use 
> warnings;                                                                  
>                                                                                 
>
> $_ = "#if __LDBL_SIZE == 80 
> block";                                            
>                                                                                 
>
> if (/^#.*= (\d*)/) 
> {                                                           
>   print "Pattern matched \$1 = 
> \"$1\"\n";                                      
> } else 
> {                                                                       
>   print "Pattern did not 
> match\n";                                             
> }                                                                               
>
>                                                                                 
>
> if (/^#.*(\d*)/) 
> {                                                             
>   print "Pattern matched \$1 = 
> \"$1\"\n";                                      
> } else 
> {                                                                       
>   print "Pattern did not 
> match\n";                                             
> }
>
> Outputs:
>
> Pattern matched $1 = 
> "80"                                                     
> Pattern matched $1 = ""
>
> Why does the second pattern fail?!?

it did not fail, it successfuly mapped \d* to an empty string.

i
-- 


------------------------------

Date: Sun, 15 May 2005 03:53:16 GMT
From: Andrew DeFaria <Andrew@DeFaria.com>
Subject: Re: Regex not matching
Message-Id: <MIzhe.524$W51.4473@typhoon.sonic.net>

Andrew DeFaria wrote:

Ugh, that messed up pretty bad. Let me try again.
I thought I understood Perl regexs pretty well but this one confuses me. 
What am I doing wrong here?

#!/usr/bin/perl                                                                 

use strict;
use 
warnings;                                                                  
                                                                               


$_ = "#if __LDBL_SIZE == 80 
block";                                            
                                                                               


if (/^#.*= (\d*)/) {
   print "Pattern matched \$1 = \"$1\"\n";
} else {
   print "Pattern did not match\n";
}                                                                               

                                                                               

if (/^#.*(\d*)/) {
  print "Pattern matched \$1 = \"$1\"\n";
} else {
  print "Pattern did not match\n";
}

Outputs:

Pattern matched $1 = "80"
Pattern matched $1 = ""

Why does the second pattern fail?!?
-- 
Not one shred of evidence supports the notion that life is serious.


------------------------------

Date: Sun, 15 May 2005 03:54:39 GMT
From: Andrew DeFaria <Andrew@DeFaria.com>
Subject: Re: Regex not matching
Message-Id: <3Kzhe.525$W51.4583@typhoon.sonic.net>

Ignoramus4744 wrote:

> On Sun, 15 May 2005 03:37:23 GMT, Andrew DeFaria <Andrew@DeFaria.com> 
> wrote:
>
>> I thought I understood Perl regexs pretty well but this one confuses me.
>> What am I doing wrong here?
>>
>> #!/usr/bin/perl
>>
>> use
>> strict;
>> use
>> warnings;
>>
>>
>> $_ = "#if __LDBL_SIZE == 80
>> block";
>>
>>
>> if (/^#.*= (\d*)/)
>> {
>> print "Pattern matched \$1 =
>> \"$1\"\n";
>> } else
>> {
>> print "Pattern did not
>> match\n";
>> }
>>
>>
>>
>> if (/^#.*(\d*)/)
>> {
>> print "Pattern matched \$1 =
>> \"$1\"\n";
>> } else
>> {
>> print "Pattern did not
>> match\n";
>> }
>>
>> Outputs:
>>
>> Pattern matched $1 =
>> "80"
>> Pattern matched $1 = ""
>>
>> Why does the second pattern fail?!?
>
>
> it did not fail, it successfuly mapped \d* to an empty string.

OK why didn't it match it to 80 like the first pattern did? Why is it 
required to have the "=" and the space in the pattern? Why wouldn't ".*" 
suck that up?
-- 
42.7 percent of all statistics are made up on the spot.


------------------------------

Date: Sat, 14 May 2005 22:56:57 -0500
From: Lars Eighner <eighner@io.com>
Subject: Re: Regex not matching
Message-Id: <slrnd8di27.a8i.eighner@goodwill.io.com>

In our last episode, 
<Ttzhe.522$W51.4695@typhoon.sonic.net>, 
the lovely and talented Andrew DeFaria 
broadcast on comp.lang.perl.misc:

> I thought I understood Perl regexs pretty well but this one confuses me. 
> What am I doing wrong here?

> #!/usr/bin/perl                                                                 

> use 
> strict;                                                                    
> use 
> warnings;                                                                  
>                                                                                 

> $_ = "#if __LDBL_SIZE == 80 
> block";                                            
>                                                                                 

> if (/^#.*= (\d*)/) 
> {                                                           
>   print "Pattern matched \$1 = 
> \"$1\"\n";                                      
> } else 
> {                                                                       
>   print "Pattern did not 
> match\n";                                             
> }                                                                               

>                                                                                 

> if (/^#.*(\d*)/) 
> {                                                             
>   print "Pattern matched \$1 = 
> \"$1\"\n";                                      
> } else 
> {                                                                       
>   print "Pattern did not 
> match\n";                                             
> }

> Outputs:

> Pattern matched $1 = 
> "80"                                                     
> Pattern matched $1 = ""

> Why does the second pattern fail?!?

Regular expressions are greedy.  ^#.* matched the whole
line including everything after = .  That left nothing to match
\d*.  (Or actually it left \d zero times to match.)

Just a guess.

-- 
Lars Eighner              eighner@io.com           http://www.larseighner.com/
                    Save the whales! Collect the whole set!


------------------------------

Date: Sun, 15 May 2005 00:28:38 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Regex not matching
Message-Id: <xIydnfI2FoBqUhvfRVn-3g@comcast.com>

Andrew DeFaria wrote:

> I thought I understood Perl regexs pretty well but this one confuses me.
> What am I doing wrong here?
> 
> #!/usr/bin/perl
> 
> use
> strict;
> use
> warnings;
>                                                                                 
> 
> $_ = "##if __LDBL_SIZE == 80
> block";
>                                                                                 
> 
> if (/^#.*= (\d*)/)

Here, the ".*" matches "if __LDBL_SIZE =", because
it must leave the "= " to match the literal.  The
"\d*" then scoops up the "80".

> {                                                           
>   print "Pattern matched \$1 =
> \"$1\"\n";
> } else
> {                                                                       
>   print "Pattern did not
> match\n";
> }
> 
>                                                                                 
> 
> if (/^#.*(\d*)/)

Because it is *greedy*, and there is no literal
to limit it, the ".*" here matches "if __LDBL_SIZE == 80".
Since "\d*" can be satisfied with no characters, no
characters is all the ".*" leaves it.

> {                                                             
>   print "Pattern matched \$1 =
> \"$1\"\n";
> } else
> {                                                                       
>   print "Pattern did not
> match\n";
> }
> 
> Outputs:
> 
> Pattern matched $1 =
> "80"
> Pattern matched $1 = ""
> 
> Why does the second pattern fail?!?

It doesn't fail.  It does exactly what you told it
to and successfully matches.  This, of course, may
not be what you *wanted*, but that's why we debug
programs :-).

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


------------------------------

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 8080
***************************************


home help back first fref pref prev next nref lref last post