[32037] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3301 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 26 14:09:26 2011

Date: Sat, 26 Feb 2011 11:09:09 -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           Sat, 26 Feb 2011     Volume: 11 Number: 3301

Today's topics:
    Re: books on perl <m@rtij.nl.invlalid>
        matching '?' in a string ending with digits <rameme@gmail.com>
    Re: matching '?' in a string ending with digits (Jens Thoms Toerring)
    Re: matching '?' in a string ending with digits <peter@makholm.net>
    Re: matching '?' in a string ending with digits sln@netherlands.com
    Re: matching '?' in a string ending with digits sln@netherlands.com
    Re: matching '?' in a string ending with digits <jurgenex@hotmail.com>
    Re: matching '?' in a string ending with digits <rameme@gmail.com>
    Re: matching '?' in a string ending with digits <rameme@gmail.com>
    Re: matching '?' in a string ending with digits <rameme@gmail.com>
    Re: newsgroups on perl <brian.d.foy@gmail.com>
    Re: Ruby on rails training for Perl developers <cwilbur@chromatico.net>
    Re: Ruby on rails training for Perl developers <cartercc@gmail.com>
    Re: Ruby on rails training for Perl developers <rvtol+usenet@xs4all.nl>
        yea, one <r@thevoid1.net>
        yea <r@thevoid1.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 25 Feb 2011 22:09:56 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: books on perl
Message-Id: <4eil38-53b.ln1@news.rtij.nl>

On Thu, 24 Feb 2011 10:43:17 -0800, Randal L. Schwartz wrote:

>>>>>> "Martijn" == Martijn Lievaart <m@rtij.nl.invlalid> writes:
> 
> Martijn> Better written as:
> 
> Martijn> $self->kick();
> 
> Martijn> although if kick() does not exist, the former fails at compile
> time while Martijn> the latter fails at run time.
> 
> And if kick doesn't know what to do with an object of the type that
> $self is, it'll have to check that itself unless it's a method call. :)

OK, so which one is preferable:

 shoot($self, $foot);

or

 $self->$shoot($foot);

:-)

Or should we introduce some form of double dispatch here, so

  shoot($self, $foot);

depends both on the type of $self as the type of $foot?.

M4


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

Date: Sat, 26 Feb 2011 08:42:29 +0000 (UTC)
From: "ReMo..." <rameme@gmail.com>
Subject: matching '?' in a string ending with digits
Message-Id: <ikaedl$spd$1@news.eternal-september.org>


#!/usr/bin/perl

use strict;
use warnings;

my @arr = ('third1000', 'third1000', 'third?1000', '1000third?', 'third{}1000');
for my $item (@arr) {
    my $targ = $item;
    print "$targ and $item ";
    print "do not " if ($item !~ /$targ/);
    print "match\n"
}

The output is:
third1000 and third1000 match
third1000 and third1000 match
third?1000 and third?1000 do not match << I don't understand this
1000third? and 1000third? match
third{}1000 and third{}1000 match

In the above, the nondigits represent arbitrary text that digits are
added to for a multi-array sort in a module I'm making, because there
may be otherwise-identical text items.

/\Q...\E/ seems to make it go away, but then two characters ('$' and '@')
would apparently need to be accounted for.

So my question is, what other characters will fail to match in a string
ending with digits?  I assume there are more clues in perlre and perlops,
but I can't find them.  I've got to be missing something really elementary
here.

-- 

"Learning is what most adults will do for a living in the 21st century." 
-- S.J. Perelman


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

Date: 26 Feb 2011 12:54:16 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: matching '?' in a string ending with digits
Message-Id: <8ssbfoF2rvU1@mid.uni-berlin.de>

ReMo... <rameme@gmail.com> wrote:
> #!/usr/bin/perl

> use strict;
> use warnings;

> my @arr = ('third1000', 'third1000', 'third?1000', '1000third?', 'third{}1000');
> for my $item (@arr) {
>     my $targ = $item;
>     print "$targ and $item ";
>     print "do not " if ($item !~ /$targ/);
>     print "match\n"
> }

> The output is:
> third1000 and third1000 match
> third1000 and third1000 match
> third?1000 and third?1000 do not match << I don't understand this
> 1000third? and 1000third? match
> third{}1000 and third{}1000 match

> In the above, the nondigits represent arbitrary text that digits are
> added to for a multi-array sort in a module I'm making, because there
> may be otherwise-identical text items.

> /\Q...\E/ seems to make it go away, but then two characters ('$' and '@')
> would apparently need to be accounted for.

> So my question is, what other characters will fail to match in a string
> ending with digits?

It's not about the digits in the end, it's about the presence
of characters that have special meanings in a regexp. Take

 'third?1000'

As a regexp it says "match everything that starts with the 4
chars 'thri', optionally followed by a 'd', and then by '1000'."
That's obviously something that doesn't describe the string
itself, which contains a question mark.

And the list of strings that you will get problems with can
easily be extended. Take, for example

 'third()1000'
 'thir\d1000'
 'thir{2,}d1000'
 'third*1000'

And it gets worse: try

 'th(ird1000'

which will end in a complaint about an unmatched '(' in a
regular expression.

>  I assume there are more clues in perlre and perlops,
> but I can't find them.  I've got to be missing something really elementary
> here.

Using '/\Q$trag\E/' will help with since for all what's en-
closed by '\Q' and '\E' the special meaning of the charac-
ters is removed. I don't see what problems you forsee with
'$' and '@', but then I don't understand the explanation of
what you're planing to do with all this.

                           Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Sat, 26 Feb 2011 13:58:10 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: matching '?' in a string ending with digits
Message-Id: <874o7rymu5.fsf@vps1.hacking.dk>

"ReMo..." <rameme@gmail.com> writes:

> So my question is, what other characters will fail to match in a string
> ending with digits?  I assume there are more clues in perlre and perlops,
> but I can't find them.  I've got to be missing something really elementary
> here.

Digits are not your problem. The problem is characters that have special
meaning in regexpes, this includes '?'. The regexp 'third?1000' matches
either 'third1000' or 'thir1000' which of course isn't a substring of
'third?1000'.

The regexp 'third1000?' matches 'third1000' and 'third100' which in both
cases are substrings of 'third1000?' and so you get a match. 

//Makholm


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

Date: Sat, 26 Feb 2011 05:30:30 -0800
From: sln@netherlands.com
Subject: Re: matching '?' in a string ending with digits
Message-Id: <9svhm6dbbn7ltko8uqq52fr4nm81guubl0@4ax.com>

On Sat, 26 Feb 2011 08:42:29 +0000 (UTC), "ReMo..." <rameme@gmail.com> wrote:

>
>#!/usr/bin/perl
>
>use strict;
>use warnings;
>
>my @arr = ('third1000', 'third1000', 'third?1000', '1000third?', 'third{}1000');
>for my $item (@arr) {
>    my $targ = $item;
>    print "$targ and $item ";
>    print "do not " if ($item !~ /$targ/);
>    print "match\n"
>}
>
>The output is:
>third1000 and third1000 match
>third1000 and third1000 match
>third?1000 and third?1000 do not match << I don't understand this

Your using the wrong operator.
Change the conditional to
  if ($item ne $targ)

Otherwise its just dumb to do something you know nothing about.
The !~ is a regular expression operator. Read any document on regular
expressions before actually trying them.

-sln


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

Date: Sat, 26 Feb 2011 05:33:26 -0800
From: sln@netherlands.com
Subject: Re: matching '?' in a string ending with digits
Message-Id: <b60im6dg1gtschvlj6fpaoil314l8hfhum@4ax.com>

On 26 Feb 2011 12:54:16 GMT, jt@toerring.de (Jens Thoms Toerring) wrote:

>ReMo... <rameme@gmail.com> wrote:
>> #!/usr/bin/perl
>
>> use strict;
>> use warnings;
>
>> my @arr = ('third1000', 'third1000', 'third?1000', '1000third?', 'third{}1000');
>> for my $item (@arr) {
>>     my $targ = $item;
>>     print "$targ and $item ";
>>     print "do not " if ($item !~ /$targ/);
>>     print "match\n"
>> }
>
>> The output is:
>> third1000 and third1000 match
>> third1000 and third1000 match
>> third?1000 and third?1000 do not match << I don't understand this
>> 1000third? and 1000third? match
>> third{}1000 and third{}1000 match
>
>> In the above, the nondigits represent arbitrary text that digits are
>> added to for a multi-array sort in a module I'm making, because there
>> may be otherwise-identical text items.
>
>> /\Q...\E/ seems to make it go away, but then two characters ('$' and '@')
>> would apparently need to be accounted for.
>
>> So my question is, what other characters will fail to match in a string
>> ending with digits?
>
>It's not about the digits in the end, it's about the presence
>of characters that have special meanings in a regexp. Take
>
> 'third?1000'
>
>As a regexp it says "match everything that starts with the 4
>chars 'thri', optionally followed by a 'd', and then by '1000'."
>That's obviously something that doesn't describe the string
>itself, which contains a question mark.
>
>And the list of strings that you will get problems with can
>easily be extended. Take, for example
>
> 'third()1000'
> 'thir\d1000'
> 'thir{2,}d1000'
> 'third*1000'
>
>And it gets worse: try
>
> 'th(ird1000'
>
>which will end in a complaint about an unmatched '(' in a
>regular expression.
>
>>  I assume there are more clues in perlre and perlops,
>> but I can't find them.  I've got to be missing something really elementary
>> here.
>
>Using '/\Q$trag\E/' will help with since for all what's en-
>closed by '\Q' and '\E' the special meaning of the charac-
>ters is removed. I don't see what problems you forsee with
>'$' and '@', but then I don't understand the explanation of
>what you're planing to do with all this.
>

This is awsome, but shouldn't you recommend he 
first looks up regular expressions at wikipedia to find
out what it is?

-sln


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

Date: Sat, 26 Feb 2011 07:59:38 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: matching '?' in a string ending with digits
Message-Id: <mh8im6lhm6s3katq97u9ibf0743ld09v0j@4ax.com>

"ReMo..." <rameme@gmail.com> wrote:
[...]
>    my $targ = $item;
>    print "$targ and $item ";
>    print "do not " if ($item !~ /$targ/);
>    print "match\n"
[...]
>So my question is, what other characters will fail to match in a string

Almost all that are special in REs. The only(?) exception being '.',
which of course will still match itself, too.

>ending with digits?  

This part of the question is a red herring. 

>I assume there are more clues in perlre and perlops,
>but I can't find them.  I've got to be missing something really elementary
>here.

The most elementary is: don't use REs unless you need RE behaviour. If
you simply want to check if one string is part of another string then
just use a plain "index()".

jue


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

Date: Sat, 26 Feb 2011 17:37:12 +0000 (UTC)
From: "ReMo..." <rameme@gmail.com>
Subject: Re: matching '?' in a string ending with digits
Message-Id: <ikbdo7$mqh$1@news.eternal-september.org>

On 2011-02-26, Jens Thoms Toerring <jt@toerring.de> wrote:
> ReMo... <rameme@gmail.com> wrote:
>> #!/usr/bin/perl
>
>> use strict;
>> use warnings;
>
>> my @arr = ('third1000','third1000','third?1000','1000third?','third{}1000');
>> for my $item (@arr) {
>>     my $targ = $item;
>>     print "$targ and $item ";
>>     print "do not " if ($item !~ /$targ/);
>>     print "match\n"
>> }
>
>> The output is:
>> third1000 and third1000 match
>> third1000 and third1000 match
>> third?1000 and third?1000 do not match << I don't understand this
>> 1000third? and 1000third? match
>> third{}1000 and third{}1000 match
>
>> In the above, the nondigits represent arbitrary text that digits are
>> added to for a multi-array sort in a module I'm making, because there
>> may be otherwise-identical text items.
>
>> /\Q...\E/ seems to make it go away, but then two characters ('$' and '@')
>> would apparently need to be accounted for.
>
>> So my question is, what other characters will fail to match in a string
>> ending with digits?
>
> It's not about the digits in the end, it's about the presence
> of characters that have special meanings in a regexp. Take
>
>  'third?1000'
>
> As a regexp it says "match everything that starts with the 4
> chars 'thri', optionally followed by a 'd', and then by '1000'."
> That's obviously something that doesn't describe the string
> itself, which contains a question mark.
>
> And the list of strings that you will get problems with can
> easily be extended. Take, for example
>
>  'third()1000'
>  'thir\d1000'
>  'thir{2,}d1000'
>  'third*1000'
>
> And it gets worse: try
>
>  'th(ird1000'
>
> which will end in a complaint about an unmatched '(' in a
> regular expression.
>
>>  I assume there are more clues in perlre and perlops,
>> but I can't find them.  I've got to be missing something really elementary
>> here.
>
> Using '/\Q$trag\E/' will help with since for all what's en-
> closed by '\Q' and '\E' the special meaning of the charac-
> ters is removed. I don't see what problems you forsee with
> '$' and '@', but then I don't understand the explanation of
> what you're planing to do with all this.

I knew it had to be that simple, but since '{' worked I assumed
without much reflection that a match should then work like a
comparison.  Thank you!

For reference, a test for the sub that the above represents is
something like:

$outee = modelsort (
                ['3third','2second','1first','1first'],
                ['alpha','beta','gamma','delta'],
                ['apple','banana','cherry','donut']
);
$complex1out =  [
                ['1first','1first','2second','3third'],
                ['gamma','delta','beta','alpha'],
                ['cherry','donut','banana','apple']
];
is_deeply ($outee, $complex1out, "modelsort: duplicate sort items");
 ...

perlre goes on to say:  'You cannot include a literal "$" or "@"
within a "\Q" sequence...'  But of course a variable isn't a literal,
which explains why I couldn't make a match on those characters
fail.  So that should work just dandy for what I'm doing.





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

Date: Sat, 26 Feb 2011 17:42:07 +0000 (UTC)
From: "ReMo..." <rameme@gmail.com>
Subject: Re: matching '?' in a string ending with digits
Message-Id: <ikbe1f$mqh$2@news.eternal-september.org>

On 2011-02-26, Peter Makholm <peter@makholm.net> wrote:
> "ReMo..." <rameme@gmail.com> writes:
>
>> So my question is, what other characters will fail to match in a string
>> ending with digits?  I assume there are more clues in perlre and perlops,
>> but I can't find them.  I've got to be missing something really elementary
>> here.
>
> Digits are not your problem. The problem is characters that have special
> meaning in regexpes, this includes '?'. The regexp 'third?1000' matches
> either 'third1000' or 'thir1000' which of course isn't a substring of
> 'third?1000'.
>
> The regexp 'third1000?' matches 'third1000' and 'third100' which in both
> cases are substrings of 'third1000?' and so you get a match. 
>
> //Makholm

Thank you.  I really and truly thought (without thinking) that
since '{' matched, the other quote operators would, also, and that
a solution was elsewhere than somehow accounting for RE metacharacters.


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

Date: Sat, 26 Feb 2011 18:35:18 +0000 (UTC)
From: "ReMo..." <rameme@gmail.com>
Subject: Re: matching '?' in a string ending with digits
Message-Id: <ikbh56$h2k$1@news.eternal-september.org>

On 2011-02-26, J?rgen Exner <jurgenex@hotmail.com> wrote:
> "ReMo..." <rameme@gmail.com> wrote:
> [...]
>>    my $targ = $item;
>>    print "$targ and $item ";
>>    print "do not " if ($item !~ /$targ/);
>>    print "match\n"
> [...]
>>So my question is, what other characters will fail to match in a string
>
> Almost all that are special in REs. The only(?) exception being '.',
> which of course will still match itself, too.
>
>>ending with digits?  
>
> This part of the question is a red herring. 
>
>>I assume there are more clues in perlre and perlops,
>>but I can't find them.  I've got to be missing something really elementary
>>here.
>
> The most elementary is: don't use REs unless you need RE behaviour. If
> you simply want to check if one string is part of another string then
> just use a plain "index()".
>
> jue

Exactly relevent principle here, because the only reason I'd like
to stick with an RE is because I have the vaguest of ideas that in
the future I might want to use a different sort strategy.  But in
fact, I don't actually need to use an RE there right now.

Thanks!



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

Date: Fri, 25 Feb 2011 03:37:37 -0800
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: newsgroups on perl
Message-Id: <250220110337370116%brian.d.foy@gmail.com>

In article <89da7$4d66a8cc$ce534406$26602@news.eurofeeds.com>, Ralph
Malph <ralph@happydays.com> wrote:

> On 2/24/2011 12:47 PM, Jim Gibson wrote:
> > In article
> > <054b8801-93a7-483b-a294-4a60676e733b@z27g2000prz.googlegroups.com>, K4
> > Monk<k4monk@gmail.com>  wrote:
> >
> >> which newsgroups (apart from comp.lang.perl.misc) are the most active
> >> in the perl community?
> >
> > perldoc -q newsgroups

> This answer is incorrect. The OP is asking about which are "most active".

The ones in the FAQ are the most active newsgroups. The FAQ also
mentions the NNTP interface to the Perl mailing lists. We write the FAQ
so you know those things. :)


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

Date: Fri, 25 Feb 2011 16:24:20 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <86sjvberjv.fsf@mithril.chromatico.net>

>>>>> "SP" == Sherm Pendley <sherm.pendley@gmail.com> writes:

    SP> ccc31807 <cartercc@gmail.com> writes:

    >> What I can't figure out is why a Perl developer would have much
    >> interest in learning Ruby.

    SP> Why would a red painter be interested in learning blue? Could
    SP> someone who only knew one color honestly claim to be a painter
    SP> to begin with?

If I were going to learn another language (and I'm not sure why I'm
phrasing this as a counterfactual conditional, but I'll run with it),
I'd pick something dramatically different from Perl.

Unless my principal motivation were to convince HR people doing keyword
searches, because I'm not comfortable putting Ruby on my resume until
I've written serious code in it.  

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Fri, 25 Feb 2011 14:26:56 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <317b0ce1-ad55-453d-81ea-a402d0e60d29@x4g2000prf.googlegroups.com>

On Feb 25, 4:24=A0pm, Charlton Wilbur <cwil...@chromatico.net> wrote:
> If I were going to learn another language (and I'm not sure why I'm
> phrasing this as a counterfactual conditional, but I'll run with it),
> I'd pick something dramatically different from Perl.

I think that a lot of this is influenced by taste. If I were going to
learn another language (and I am constantly studying/reading about at
least one other language) I would choose a language that lets me do
something that Perl can't do well. Current example: R.

> Unless my principal motivation were to convince HR people doing keyword
> searches, because I'm not comfortable putting Ruby on my resume until
> I've written serious code in it. =A0

If you know how to program, you can program in Ruby, or Python, and so
on. The problem with HR people is that they are (mostly) checking
boxes. You have to talk to the technical guys to see what they really
need, and even if they need someone that knows a particular language,
they can deal with a lack of experience if you bring other things to
the table.

I look and evaluate resumes occasionally, and occasionally sit in on
interviews, and based on this experience you can't depend on someone's
self evaluation as shown on their resume. Recent example: an applicant
who had a Windows OS certification who wasn't able to configure the
permissions of a new user on a server.

CC.


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

Date: Fri, 25 Feb 2011 23:52:46 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Ruby on rails training for Perl developers
Message-Id: <4d6832bf$0$41110$e4fe514c@news.xs4all.nl>

On 2011-02-25 23:26, ccc31807 wrote:

> If I were going to
> learn another language (and I am constantly studying/reading about at
> least one other language) I would choose a language that lets me do
> something that Perl can't do well. Current example: R.

http://pdl.perl.org/
:)

-- 
Ruud



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

Date: Fri, 25 Feb 2011 09:52:04 -0800 (PST)
From: Robin <r@thevoid1.net>
Subject: yea, one
Message-Id: <e85071f3-61a1-4232-8fd0-c4535ca4390a@22g2000prx.googlegroups.com>

you did get, stop war


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

Date: Fri, 25 Feb 2011 09:49:24 -0800 (PST)
From: Robin <r@thevoid1.net>
Subject: yea
Message-Id: <89193237-659c-47ce-8b6a-f3162db03123@d12g2000prj.googlegroups.com>

you  did get.... stop war


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3301
***************************************


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