Click here to get back home

Why reading the FAQs is good (example)

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Why reading the FAQs is good (example) Marc Bissonnette 05-25-2008
Posted by Marc Bissonnette on May 26, 2008, 1:11 am
Please log in for more thread options

>
> on the MB> keyboard. This was the result:
>
>
> >> /^\+?-?\d?\.?\d*$/
>
> MB> Apologies for following up my own post: I just realized the
> above has a MB> flaw: It matches on or zero beginning digits (.4 or
> 0.4) but not two digits MB> or more (22.4)
>
> MB> This works better:
>
> MB> /^\+?-?(\d?|\d+)\.?\d*$/
>
> the middle part is silly. it matches 0 or 1 digit OR one or more
> digits. that is the same as 0 or more digits which is \d* all by
> itself.
>
> but you can't use \d*\.?\d* as that will match the empty string (as
> will your regex above). everything in yours is optional. look at this:
>
> perl -ne 'print "yes\n" if /^\+?-?(\d?|\d+)\.?\d*$/'
>
> yes
> +
> yes
> +-
> yes
>
> note that the blank line was input. as i said, matching decimal
> numbers is not trivial. use regexp::common as it has solved that
> problem.

Many thanks for the pointers and solution - I will indeed look into
regexp::common

At the very least, it's been instructional/educational - As I mentioned,
I've got a few bad habits and long-ways-around-the-bush to correct :)


--
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.

Posted by Gordon Etly on May 26, 2008, 9:50 am
Please log in for more thread options
Marc Bissonnette wrote:

> > note that the blank line was input. as i said, matching decimal
> > numbers is not trivial. use regexp::common as it has solved that
> > problem.

> Many thanks for the pointers and solution - I will indeed look into
> regexp::common

It's actually Regexp::Common. The casing makes a difference if
installing from the CPAN command-line, as well as when 'use'ing the
module. I would thing Uri would know that.

--
G.Etly



Posted by Marc Bissonnette on May 26, 2008, 9:58 am
Please log in for more thread options

> Marc Bissonnette wrote:
>
>> > note that the blank line was input. as i said, matching decimal
>> > numbers is not trivial. use regexp::common as it has solved that
>> > problem.
>
>> Many thanks for the pointers and solution - I will indeed look into
>> regexp::common
>
> It's actually Regexp::Common. The casing makes a difference if
> installing from the CPAN command-line, as well as when 'use'ing the
> module. I would thing Uri would know that.

Yep, I always do the search from the CPAN command line before the
installation. While I know there are all lower-case modules out there, I
don't think I've ever installed one (odd point, but...)


--
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.

Posted by Tad J McClellan on May 26, 2008, 11:30 am
Please log in for more thread options
Marc Bissonnette <dragnet> wrote:

> While I know there are all lower-case modules out there, I
> don't think I've ever installed one (odd point, but...)


Modules named in all-lowercase are pragmas (compiler hints) by convention.

(see "Pragmatic Modules" in perldoc perlmodlib.)

So they (mostly?) are installed along with the perl distribution.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Posted by Uri Guttman on May 27, 2008, 12:38 pm
Please log in for more thread options

s> Abigail wrote:

>> Note that using lowercase for "pragmata" is just a convention. Perl
>> itself doesn't care at all about the casing (as long as it matches),
>> nor does

s> Doesn't "care" where? In the 'use' statement, it most certainly does
s> matter. And if you install every module as lowercase, you're definitely
s> going to have problems running someone else's code that uses the correct
s> casing. Saying Perl doesn't care about casing is misleading at best. In
s> general, casing in Perl matters very much.

you didn't read abigail's post correctly. he means that the case of the
name doesn't matter in regards to what kind of module (pragma or not) it
is. the convention (not a syntax or semantic requirement) is pragmas are
named in all lower case and regular modules are in StudlyCaps. this has
nothing to do with the use statement nor about case matching of file
names.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

Similar ThreadsPosted
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, April 21, 2005, 1:25 pm
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, April 22, 2005, 3:33 pm
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, April 24, 2005, 6:50 pm
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, May 1, 2005, 11:27 am
Good documentation or good source examples for Image::Magick or converter from commandline to perl April 1, 2008, 5:23 pm
small mistake: http://perl.plover.com/FAQs/Namespaces.html July 3, 2007, 5:27 pm
QC: good function? July 16, 2004, 12:24 am
need a good tutorial August 25, 2004, 11:31 pm
2 methods to get the domains's IP,but neither of them is good. August 1, 2004, 1:56 pm
Good way to un-chomp an array August 13, 2004, 9:10 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap