[30932] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2177 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 2 03:09:44 2009

Date: Mon, 2 Feb 2009 00:09:07 -0800 (PST)
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, 2 Feb 2009     Volume: 11 Number: 2177

Today's topics:
        new CPAN modules on Mon Feb  2 2009 (Randal Schwartz)
    Re: perl qt with cygwin? <rabbits77@my-deja.com>
    Re: Regex problem from book, please help with solution sharma__r@hotmail.com
    Re: Regex problem from book, please help with solution <noone@none.net>
    Re: Regex problem from book, please help with solution <noone@none.net>
    Re: Regex problem from book, please help with solution <tim@burlyhost.com>
    Re: Regex problem from book, please help with solution <tadmc@seesig.invalid>
    Re: Regex problem from book, please help with solution <burner+usenet@imf.au.dk>
    Re: Regex problem from book, please help with solution <tim@burlyhost.com>
    Re: Regex problem from book, please help with solution (Vicky Conlan)
    Re: Regex problem from book, please help with solution <noone@none.net>
    Re: Regex problem from book, please help with solution <tim@burlyhost.com>
    Re: Regex problem from book, please help with solution <whynot@pozharski.name>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 2 Feb 2009 05:42:25 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Feb  2 2009
Message-Id: <KEFBup.1nA4@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.

Apache2-ASP-2.22
http://search.cpan.org/~johnd/Apache2-ASP-2.22/
ASP for Perl, reloaded. 
----
CGI-Application-Plugin-Email-0.01
http://search.cpan.org/~cosmicnet/CGI-Application-Plugin-Email-0.01/
Lazy loaded Email 
----
CGI-Application-Plugin-YAML-0.03
http://search.cpan.org/~cosmicnet/CGI-Application-Plugin-YAML-0.03/
YAML methods for CGI::App 
----
CGI-UploadEasy-1.00
http://search.cpan.org/~gunnar/CGI-UploadEasy-1.00/
Facilitate file uploads 
----
CPAN-1.93_03
http://search.cpan.org/~andk/CPAN-1.93_03/
query, download and build perl modules from CPAN sites 
----
CPAN-1.93_51
http://search.cpan.org/~andk/CPAN-1.93_51/
query, download and build perl modules from CPAN sites 
----
CPANPLUS-Dist-Mdv-1.0.0
http://search.cpan.org/~jquelin/CPANPLUS-Dist-Mdv-1.0.0/
a cpanplus backend to build mandriva rpms 
----
Catalyst-Authentication-Store-Tangram-0.007
http://search.cpan.org/~bobtfish/Catalyst-Authentication-Store-Tangram-0.007/
A storage class for Catalyst authentication from a class stored in Tangram 
----
Catalyst-View-TT-ForceUTF8-0.11
http://search.cpan.org/~lyokato/Catalyst-View-TT-ForceUTF8-0.11/
Template View Class with utf8 encoding 
----
Class-Sniff-0.02
http://search.cpan.org/~ovid/Class-Sniff-0.02/
Look for class composition code smells 
----
Class-Sniff-0.03
http://search.cpan.org/~ovid/Class-Sniff-0.03/
Look for class composition code smells 
----
Devel-Pragma-0.40
http://search.cpan.org/~chocolate/Devel-Pragma-0.40/
helper functions for developers of lexical pragmas 
----
Email-Sender-0.002
http://search.cpan.org/~rjbs/Email-Sender-0.002/
a library for sending email 
----
Encode-2.29
http://search.cpan.org/~dankogai/Encode-2.29/
character encodings 
----
Finance-Bank-IE-PermanentTSB-0.3
http://search.cpan.org/~pallotron/Finance-Bank-IE-PermanentTSB-0.3/
Perl Interface to the PermanentTSB Open24 homebanking on <http://www.open24.ie> 
----
Games-Framework-RCP-0.03_01
http://search.cpan.org/~wolfman/Games-Framework-RCP-0.03_01/
Generic video game tactics based battle system. 
----
Getopt-Abridged-v0.0.1
http://search.cpan.org/~ewilhelm/Getopt-Abridged-v0.0.1/
quick and simple full-featured option handling 
----
Getopt-Base-v0.0.2
http://search.cpan.org/~ewilhelm/Getopt-Base-v0.0.2/
foundation for oo GetOpt support 
----
HTTP-Session-0.29
http://search.cpan.org/~tokuhirom/HTTP-Session-0.29/
simple session 
----
Hash-FieldHash-0.01
http://search.cpan.org/~gfuji/Hash-FieldHash-0.01/
A lightweight fieldhash implementation 
----
IO-Async-Loop-IO_Ppoll-0.02
http://search.cpan.org/~pevans/IO-Async-Loop-IO_Ppoll-0.02/
a Loop using an IO::Ppoll object 
----
IO-Moose-0.09
http://search.cpan.org/~dexter/IO-Moose-0.09/
Reimplementation of IO::* with improvements 
----
IPDevice-Allnet-ALL4000-0.13
http://search.cpan.org/~rcl/IPDevice-Allnet-ALL4000-0.13/
provides an interface to ALL4000 ethernet sensormeter 
----
LWP-ConnCache-MaxKeepAliveRequests-0.32
http://search.cpan.org/~lbrocard/LWP-ConnCache-MaxKeepAliveRequests-0.32/
A connection cache that enforces a max keep alive limit 
----
MediaWiki-Bot-Plugin-SE-0.1.0
http://search.cpan.org/~dcollins/MediaWiki-Bot-Plugin-SE-0.1.0/
a plugin for MediaWiki::Bot which contains data retrieval tools for the 2009 Steward elections 
----
MooseX-Params-Validate-0.08
http://search.cpan.org/~drolsky/MooseX-Params-Validate-0.08/
an extension of Params::Validate for using Moose's types 
----
MooseX-Params-Validate-0.09
http://search.cpan.org/~drolsky/MooseX-Params-Validate-0.09/
an extension of Params::Validate for using Moose's types 
----
MooseX-Types-UUID-0.02
http://search.cpan.org/~jrockway/MooseX-Types-UUID-0.02/
UUID type for Moose classes 
----
Net-SSH-Perl-1.34
http://search.cpan.org/~turnstep/Net-SSH-Perl-1.34/
Perl client Interface to SSH 
----
PAR-0.985_01
http://search.cpan.org/~smueller/PAR-0.985_01/
Perl Archive Toolkit 
----
PAR-Repository-0.18_01
http://search.cpan.org/~smueller/PAR-Repository-0.18_01/
Create and modify PAR repositories 
----
PAR-Repository-Client-0.23_01
http://search.cpan.org/~smueller/PAR-Repository-Client-0.23_01/
Access PAR repositories 
----
POE-XS-Loop-Poll-0.007
http://search.cpan.org/~tonyc/POE-XS-Loop-Poll-0.007/
an XS implementation of POE::Loop, using poll(2). 
----
Padre-0.26
http://search.cpan.org/~jquelin/Padre-0.26/
Perl Application Development and Refactoring Environment 
----
Padre-Plugin-AcmePlayCode-0.07
http://search.cpan.org/~fayland/Padre-Plugin-AcmePlayCode-0.07/
Acme::PlayCode Plugin for Padre 
----
Padre-Plugin-Alarm-0.03
http://search.cpan.org/~fayland/Padre-Plugin-Alarm-0.03/
Alarm Clock in Padre 
----
Padre-Plugin-CSS-0.05
http://search.cpan.org/~fayland/Padre-Plugin-CSS-0.05/
Padre and CSS 
----
Padre-Plugin-Encrypt-0.05
http://search.cpan.org/~fayland/Padre-Plugin-Encrypt-0.05/
encrypt/decrypt file in Padre 
----
Padre-Plugin-HTML-0.08
http://search.cpan.org/~fayland/Padre-Plugin-HTML-0.08/
Padre and HTML 
----
Padre-Plugin-HTMLExport-0.04
http://search.cpan.org/~fayland/Padre-Plugin-HTMLExport-0.04/
export highlighted HTML in Padre 
----
Padre-Plugin-JavaScript-0.25
http://search.cpan.org/~fayland/Padre-Plugin-JavaScript-0.25/
Padre and JavaScript 
----
Padre-Plugin-PerlCritic-0.06
http://search.cpan.org/~kaare/Padre-Plugin-PerlCritic-0.06/
Analyze perl files with Perl::Critic 
----
Padre-Plugin-SpellCheck-0.01
http://search.cpan.org/~fayland/Padre-Plugin-SpellCheck-0.01/
Spell Check in Padre 
----
Padre-Plugin-ViewInBrowser-0.06
http://search.cpan.org/~fayland/Padre-Plugin-ViewInBrowser-0.06/
view selected doc in browser for Padre 
----
Padre-Plugin-XML-0.05
http://search.cpan.org/~fayland/Padre-Plugin-XML-0.05/
Padre and XML 
----
Parse-Method-Signatures-1.001001
http://search.cpan.org/~ash/Parse-Method-Signatures-1.001001/
Perl6 like method signature parser 
----
Perl-Critic-1.096
http://search.cpan.org/~elliotjs/Perl-Critic-1.096/
Critique Perl source code for best-practices. 
----
PerlIO-via-csv-0.01
http://search.cpan.org/~slanning/PerlIO-via-csv-0.01/
PerlIO layer to convert between Excel and CSV 
----
PerlIO-via-json-0.01
http://search.cpan.org/~slanning/PerlIO-via-json-0.01/
PerlIO layer to convert to and from JSON 
----
Set-Relation-0.1.0
http://search.cpan.org/~duncand/Set-Relation-0.1.0/
Relation data type for Perl 
----
String-Tagged-0.01
http://search.cpan.org/~pevans/String-Tagged-0.01/
string buffers with value tags on extents 
----
String-Urandom-0.04
http://search.cpan.org/~mbrooks/String-Urandom-0.04/
Generate a truely random string 
----
Syntax-Highlight-Mason-1.22
http://search.cpan.org/~laxen/Syntax-Highlight-Mason-1.22/
Perl extension to Highlight HTML::Mason code 
----
Syntax-Highlight-Mason-1.23
http://search.cpan.org/~laxen/Syntax-Highlight-Mason-1.23/
Perl extension to Highlight HTML::Mason code 
----
TeamCity-BuildMessages-v0.999.2
http://search.cpan.org/~elliotjs/TeamCity-BuildMessages-v0.999.2/
Encode and emit messages that TeamCity can interpret during a build. 
----
Template-Plugin-Komma-0.07
http://search.cpan.org/~uvoelker/Template-Plugin-Komma-0.07/
TT2 plugin to commify numbers (German format) 
----
Tk-PathEntry-3.02
http://search.cpan.org/~srezic/Tk-PathEntry-3.02/
Entry widget for selecting paths with completion 
----
Unix-Uptime-0.31_01
http://search.cpan.org/~pioto/Unix-Uptime-0.31_01/
Determine the current uptime, in seconds, across different *NIX architectures 
----
Vim-Snippet-Converter-0.07
http://search.cpan.org/~cornelius/Vim-Snippet-Converter-0.07/
A Template Converter for Slippery Snippet Vim Plugin 
----
WWW-Shorten-Bitly-0.93
http://search.cpan.org/~pjain/WWW-Shorten-Bitly-0.93/
Interface to shortening URLs using <http://bit.ly> 
----
WebService-Simple-0.15
http://search.cpan.org/~yusukebe/WebService-Simple-0.15/
Simple Interface To Web Services APIs 
----
XML-RPC-Fast-0.3
http://search.cpan.org/~mons/XML-RPC-Fast-0.3/
Faster implementation for an XML-RPC client and server (based on XML::RPC) 


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/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Sun, 01 Feb 2009 15:11:21 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: perl qt with cygwin?
Message-Id: <9637a$498601f3$d0365e12$10408@news.eurofeeds.com>

zentara wrote:
> On Sat, 31 Jan 2009 23:58:54 -0800 (PST), Owen <xemoth@gmail.com> wrote:
> 
>> On Jan 31, 4:40 pm, rabbits77 <rabbit...@my-deja.com> wrote:
>>> Owen wrote:
>>>> On Jan 31, 9:15 am, rabbits77 <rabbit...@my-deja.com> wrote:
>>>>> I am trying to get perl qt to work under cygwin
>>>>> and am not having much luck.
>>>>> I have KDE and QT installed. Everything should just compile and go
>>>>> but this is not the case.
>>>>> Googling reveals nothing but very old threads from various sources
>>>>> that don't help.
>>>>> Does anyone have any advice on how to get perl qt running under cygwin?
>>>> Are their any error messages?
>>> No matter what I do it always fails with a complaint that it cannot find
>>> kde-config.
> 
> As far as I know, the Perl Qt module is very old and has not been
> keeping up with KDE development....  so unless you have found some new
> version of Perl/Qt, just forget about using it, it is obsolete and not
> actively maintained.  The module on CPAN is version 0.03 and dated 1997.
I am trying one from Sourceforge. The release is dated 10 July 2005.
http://sourceforge.net/projects/perlqt


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

Date: Sun, 1 Feb 2009 11:13:02 -0800 (PST)
From: sharma__r@hotmail.com
Subject: Re: Regex problem from book, please help with solution
Message-Id: <b8ab4831-d622-4485-9ad8-791a4207f8fa@i18g2000prf.googlegroups.com>

try this pattern:

#!/usr/local/bin/perl -w
use strict;
local $\ =3D qq{\n};

my $time_RE =3D qr{
   \A
       (?: [1-9] | 1[0-2] )

       [:]

       [0-5][0-9]

       (?: [ap]m | [AP]M )
   \z
}xms;

my @time =3D qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm );

for my $cur_time ( @time ) {
   print $cur_time if $cur_time =3D~ m/$time_RE/;
}
__END__



On Feb 1, 10:30=A0pm, noone <no...@none.net> wrote:
> I'm reading Sams Teach Yourself Perl in 24 Hours, 2nd edition. In the
> chapter about regex, there is an activity:
>
> "See whether you can produce a pattern to match a standard time format.
> All the following should be acceptable: 12:00am, 5:00pm, 8:30AM. These
> should probably not be accepted: 3:00, 2:60am, 99:00am, 3:0pm."
>
> I did this:
> @time=3Dqw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm );
> if (m/^?\d:[0-59]\w?/)
> {
> =A0 =A0 =A0 =A0 print "$_\n";}
>
> ;
>
> and i thought it matched everything but 2:60, but now it doesn't work at
> all. regardless, i don't know how to make the appropriate pattern
>


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

Date: 01 Feb 2009 20:34:52 GMT
From: noone <noone@none.net>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <4986076c$0$4857$9a6e19ea@unlimited.newshosting.com>

On Sun, 01 Feb 2009 09:58:09 -0800, Tim Greer wrote:

> noone wrote:
> 
>> I'm reading Sams Teach Yourself Perl in 24 Hours, 2nd edition. In the
>> chapter about regex, there is an activity:
>> 
>> "See whether you can produce a pattern to match a standard time format.
>> All the following should be acceptable: 12:00am, 5:00pm, 8:30AM. These
>> should probably not be accepted: 3:00, 2:60am, 99:00am, 3:0pm."
>> 
>> I did this:
>> @time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm ); if
>> (m/^?\d:[0-59]\w?/)
>> {
>> print "$_\n";
>> }
>> ;
> I don't know anything of that book or what code you're using that isn't
> shown in your above example, and I fail to understand why you wrote the
> above regex the way you did, but going from your requirement off the top
> of my head, I'd probably do some matching like:
Sorry, that I wasn't clear enough. The part starting with "I did this:" 
is my attempt at the solution. That little bit of (crappy) code is mine, 
not the book's. The activity in question was at the end of the chapter 
for regex and was an attempt on the author's part to get the reader to 
test themself. 
 
> print "$_\n" if /^(?:[1-9]|1[0-2]):[0-5][0-9][ap]m$/i;
> 
> Anyway, I'm pretty sure the code you have typed or pasted above is not
> what's in the book.  Please type of paste the relevant code, rather than
> what you've done... or is that really what the book shows?
There was no further code, the short paragraph of instructions for 
writing the code. 

Thanks for your help.


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

Date: 01 Feb 2009 20:44:52 GMT
From: noone <noone@none.net>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <498609c4$0$4857$9a6e19ea@unlimited.newshosting.com>

On Sun, 01 Feb 2009 18:13:22 +0000, Vicky Conlan wrote:
 
> Put a foreach around it so it loops over the values of @time:
That's what I had. I had deleted that line at some point. I put it back 
and now it half-works. It still matches for the stuff I don't want, like 
"3:0pm", but at least it iterates through the list.

> my @time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm ); foreach
> (@time) {
> 	if (m/^?\d:[0-59]\w?/) {
>                 print "$_\n";
> 	}
> }
> 
> Although your next question shuld probably be "why does it print 3:00
> and not 2:60", cos I can't see why right now.  :-/
well, for some reason, "[0-59]" seems to work for the right side of the 
":". But when I try "[0-12]" for the left side, it doesn't match anything 
but "12:00am". 
That's been my main trip-up. Why does a bracket pair with a specific 
range work on one side of :, but not on the the other side? I tried \d. I 
was going to use m/^?\d{2}... and then $1<13 for the right side, but 
since I was getting no matches at all, the inequality was useless.

Thanks for your help.
jo


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

Date: Sun, 01 Feb 2009 12:52:04 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <VXnhl.4441$io5.3759@newsfe09.iad>

noone wrote:

> On Sun, 01 Feb 2009 09:58:09 -0800, Tim Greer wrote:
> 
>> noone wrote:
>> 
>>> I'm reading Sams Teach Yourself Perl in 24 Hours, 2nd edition. In
>>> the chapter about regex, there is an activity:
>>> 
>>> "See whether you can produce a pattern to match a standard time
>>> format. All the following should be acceptable: 12:00am, 5:00pm,
>>> 8:30AM. These should probably not be accepted: 3:00, 2:60am,
>>> 99:00am, 3:0pm."
>>> 
>>> I did this:
>>> @time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm ); if
>>> (m/^?\d:[0-59]\w?/)
>>> {
>>> print "$_\n";
>>> }
>>> ;
>> I don't know anything of that book or what code you're using that
>> isn't shown in your above example, and I fail to understand why you
>> wrote the above regex the way you did, but going from your
>> requirement off the top of my head, I'd probably do some matching
>> like:
> Sorry, that I wasn't clear enough. The part starting with "I did
> this:" is my attempt at the solution. That little bit of (crappy) code
> is mine, not the book's. The activity in question was at the end of
> the chapter for regex and was an attempt on the author's part to get
> the reader to test themself.
>  
>> print "$_\n" if /^(?:[1-9]|1[0-2]):[0-5][0-9][ap]m$/i;
>> 
>> Anyway, I'm pretty sure the code you have typed or pasted above is
>> not
>> what's in the book.  Please type of paste the relevant code, rather
>> than what you've done... or is that really what the book shows?
> There was no further code, the short paragraph of instructions for
> writing the code.
> 
> Thanks for your help.

I gave you the solution above.  Going by the example you have tried, you
should probably go back and re-read the chapter, because your solution
was very far off from what you needed.  I don't say that to be mean,
just that you need to go back, read and understand it.  Also, consider
getting a book people can trust and recommend, such as Learning Perl,
by O'Reilly.  It's the standard and will serve you well.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Sun, 1 Feb 2009 14:51:39 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <slrngoc2qr.j2q.tadmc@tadmc30.sbcglobal.net>

noone <noone@none.net> wrote:
> On Sun, 01 Feb 2009 18:13:22 +0000, Vicky Conlan wrote:
>  
>> Put a foreach around it so it loops over the values of @time:
> That's what I had. I had deleted that line at some point. I put it back 
> and now it half-works. It still matches for the stuff I don't want, like 
> "3:0pm", but at least it iterates through the list.
>
>> my @time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm ); foreach
>> (@time) {
>> 	if (m/^?\d:[0-59]\w?/) {
>>                 print "$_\n";
>> 	}
>> }
>> 
>> Although your next question shuld probably be "why does it print 3:00
>> and not 2:60", cos I can't see why right now.  :-/
> well, for some reason, "[0-59]" 


You misunderstand what a character class does.

A character class always matches exactly one character.

What you have does NOT match numbers between 0 and 59, because all
of the numbers greater than 9 consist of more than one character.

The char class you have above is simply a shorter way of writing this:

    [0123459]

or this

    (0|1|2|3|4|5|9)


> seems to work for the right side of the 
> ":". But when I try "[0-12]" 


That is a longer way of writing this equivalent class:

   [012]

which is also equivalent to:

   [201]

and

   [210]

the order of characters in a char class does not matter.


> for the left side, it doesn't match anything 
> but "12:00am". 


because that has only the 3 characters that you've allowed.


> That's been my main trip-up. Why does a bracket pair with a specific 
> range work on one side of :, but not on the the other side?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 01 Feb 2009 22:01:54 +0100
From: Rasmus Villemoes <burner+usenet@imf.au.dk>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <u0lr62han25.fsf@orc02.imf.au.dk>

noone <noone@none.net> writes:

> well, for some reason, "[0-59]" seems to work for the right side of the 
> ":".

It doesn't. [0-59] means "match any character in the range 0-5, or the
character 9". Try 'for (0..20) { print if m/^[0-59]$/; }' and watch
the output.

> But when I try "[0-12]" for the left side, it doesn't match anything
> but "12:00am".

Well, [0-12] is equivalent to [0-2]. So it probably matches the 2 of
12.

-- 
Rasmus Villemoes
<http://rasmusvillemoes.dk/>


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

Date: Sun, 01 Feb 2009 13:06:16 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <l9ohl.2874$%j5.2844@newsfe10.iad>

noone wrote:

> On Sun, 01 Feb 2009 18:13:22 +0000, Vicky Conlan wrote:
>  
>> Put a foreach around it so it loops over the values of @time:
> That's what I had. I had deleted that line at some point. I put it
> back and now it half-works. It still matches for the stuff I don't
> want, like "3:0pm", but at least it iterates through the list.
> 
>> my @time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm ); foreach
>> (@time) {
>> if (m/^?\d:[0-59]\w?/) {
>>                 print "$_\n";
>> }
>> }
>> 
>> Although your next question shuld probably be "why does it print 3:00
>> and not 2:60", cos I can't see why right now.  :-/
> well, for some reason, "[0-59]" seems to work for the right side of
> the ":".
> But when I try "[0-12]" for the left side, it doesn't match 
> anything but "12:00am".
> That's been my main trip-up. Why does a bracket pair with a specific
> range work on one side of :, but not on the the other side? I tried
> \d. I was going to use m/^?\d{2}... and then $1<13 for the right side,
> but since I was getting no matches at all, the inequality was useless.
> 
> Thanks for your help.
> jo

Your exactly is very, very far from what you need.  Consider:

my @time = qw( 12:00am 19:03pm 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm );

for (@time) {
        print "$_\n" if /^(?:[1-9]|1[0-2]):[0-5][0-9][ap]m$/i;
}

This will loop over the @time array, and each entry will be tested
against the regular expression, before it prints the output (and only
if it's what you want).

^ is the start of the string.
(?:...) means to have an optional match, but don't capture it ?:
[1-9] is a character class, 1 through 9 (one number only)
I.e., 1:24pm, 9:40am, etc. for 1 and 9, respectively.
| (or)
1 followed by 0, 1 or 2 -> 1[0-2]
So the first one is a single digit (1-9) (since you don't want 01:30pm,
we start at 1 instead of 0). i.e., 1 to 9 am/pm.  Or (|) 10, 11, 12 (
[0-2]) am/pm.  So you have 1: to 12:
: (obvious, the colon character)
followed by [0-5][0-9], which is 0 to 5 and 0 to 9.  The first class
would only be 0-5, since you don't have above 5_ minutes (_ = 0-9), so
you have from :00 to :59.
[ap] is a character class of either a or p, followed by an "m", so [ap]m
matches either am or pm. 
$ is the end of the string.
/i is case insensitive, so it'll match AM, am, PM, pm, Am, Pm, pM, etc.

Your example:
m/^?\d:[0-59]\w?/

Will match the start of a string (or not) any single digit (will only
match from 0-9, not 10, 11 or 12, a colon and then 0, 1, 2, 3, 4, 5, or
9, then a single word character (0-9, a-z or an underscore), which is
optional due to the ? character.  So, "Blah9:0F" would match, and so
would 4:2 or 9:0G. The only one is will NOT match on your list, is
2:60, since you have no 6 in your :[0-59] character class.  That's
saying 0 TO 5 and 9 are the only numbers it'll match.  It _would_ match
2:06, ironically, since \w? would cover the "6" in :[0-59]\w?.

I recommend you re-read the entire chapter you have this test for.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Sun, 1 Feb 2009 22:57:58 +0000 (UTC)
From: comps@riffraff.plig.net (Vicky Conlan)
Subject: Re: Regex problem from book, please help with solution
Message-Id: <gm59dm$10kj$1@magenta.plig.net>

According to <sln@netherlands.com>:
>>my @time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm );
>>foreach (@time) {
>>	if (m/^?\d:[0-59]\w?/) {
>                    ^^^^
>       [0123459] ie: 0 through 5 and 9, no 6 in there

Arrgh, should have spotted that.  Ta.

-- 


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

Date: 02 Feb 2009 00:01:14 GMT
From: noone <noone@none.net>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <498637ca$0$4913$9a6e19ea@unlimited.newshosting.com>

On Sun, 01 Feb 2009 13:06:16 -0800, Tim Greer wrote:

> noone wrote:
> 
>> On Sun, 01 Feb 2009 18:13:22 +0000, Vicky Conlan wrote:

> 5 and 9 are the only numbers it'll match.  It _would_ match 2:06,
> ironically, since \w? would cover the "6" in :[0-59]\w?.
> 
> I recommend you re-read the entire chapter you have this test for.
Tim,
I went and reread all of your other comments along with this one. I 
appreciate all the help. For some reason, when I tried the solution from 
your 1st reply, it didn't work, I must have made a typo. It's fine this 
time around. 

Thanks to everyone else who offered assistance as well. Chances are, I'll 
be bothering y'all again. 

jo


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

Date: Sun, 01 Feb 2009 16:56:17 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <Rwrhl.4918$UX6.2259@newsfe14.iad>

noone wrote:

> On Sun, 01 Feb 2009 13:06:16 -0800, Tim Greer wrote:
> 
>> noone wrote:
>> 
>>> On Sun, 01 Feb 2009 18:13:22 +0000, Vicky Conlan wrote:
> 
>> 5 and 9 are the only numbers it'll match.  It _would_ match 2:06,
>> ironically, since \w? would cover the "6" in :[0-59]\w?.
>> 
>> I recommend you re-read the entire chapter you have this test for.
> Tim,
> I went and reread all of your other comments along with this one. I
> appreciate all the help. For some reason, when I tried the solution
> from your 1st reply, it didn't work, I must have made a typo. It's
> fine this time around.
> 
> Thanks to everyone else who offered assistance as well. Chances are,
> I'll be bothering y'all again.
> 
> jo

Glad it worked for you, and I hope you understood the details of it. 
Also, that was just one of several ways you could go about doing it and
I have no idea how relevant it was to the teachings and examples were
in the book you are using to learn.  If it was too far from what it
touched on, it might not help in your learning, so definitely check out
Learning Perl by O'Reilly.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Mon, 02 Feb 2009 03:01:46 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Regex problem from book, please help with solution
Message-Id: <slrngochfp.lv1.whynot@orphan.zombinet>

On 2009-02-01, Vicky Conlan <comps@riffraff.plig.net> wrote:
> According to <noone@none.net>:
>>I did this:
>>@time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm );
>>if (m/^?\d:[0-59]\w?/)
>>{
>>	print "$_\n";
>>}
>>;
>>
>>and i thought it matched everything but 2:60, but now it doesn't work at 
>>all. regardless, i don't know how to make the appropriate pattern 
>>according to the directions provided. can someone help?
>
> If that's all your code, you don't have anything in $_ by the time you 
> reach the RE. (I think if you "use warnings" it will show you this)
>
> Put a foreach around it so it loops over the values of @time:
>
> my @time=qw( 12:00am 5:00pm 3:00 2:60 8:30AM 99:00AM 3:0pm );
> foreach (@time) {
> 	if (m/^?\d:[0-59]\w?/) {
>                 print "$_\n";
> 	}
> }
>
> Although your next question shuld probably be "why does it print 3:00
> and not 2:60", cos I can't see why right now.  :-/
>

Wow!  ROTFL!  We here (I meant in our culture) have an anecdote about
queen that was able to make 4 mistakes in 3-letter word.  That's a kind
of!

1st -- OP matches begining of line C<qr/^?/> nil or one time.  As a
result -- it doesn't matter.

2nd -- OP matches exactly one of C<qw| 0 1 2 3 4 5 9 |>.  As a result he
misses C<'2:60'> -- look how DWIM fails miserably.

3rd -- OP matches trailing alphanumeric one or more time.  As a result
he gets C<'3:0pm'>.

p.s.  Anyway, thanks to OP -- I know a bit more about I<-D512> now.

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

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


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