[32096] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3360 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 22 00:09:27 2011

Date: Thu, 21 Apr 2011 21:09:08 -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           Thu, 21 Apr 2011     Volume: 11 Number: 3360

Today's topics:
    Re: A regex to search for numeric ranges... <uri@StemSystems.com>
    Re: A regex to search for numeric ranges... <*@eli.users.panix.com>
    Re: FAQ 3.8 Is there a pretty-printer (formatter) for P <brian.d.foy@gmail.com>
    Re: FAQ 4.44 How do I test whether two arrays or hashes <zjsmallz@os2world.net>
    Re: FAQ 4.44 How do I test whether two arrays or hashes <tadmc@seesig.invalid>
    Re: for @{ my $x } on Perl 5.10 (bug?) <john@castleamber.com>
    Re: grabbing a facebook group <Uno@example.invalid>
    Re: grabbing a facebook group <uri@StemSystems.com>
    Re: grabbing a facebook group <tadmc@seesig.invalid>
    Re: Perl RegExp question <cartercc@gmail.com>
    Re: Perl RegExp question <john@castleamber.com>
    Re: Web Scraping Proxy <*@eli.users.panix.com>
    Re: Web Scraping Proxy <Groleau+news@FreeShell.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 20 Apr 2011 21:41:23 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: A regex to search for numeric ranges...
Message-Id: <87y634mldo.fsf@quad.sysarch.com>

>>>>> "s" == sln  <sln@netherlands.com> writes:

  s> /[256-1024]/ is generally possible.

  s> It has limitations that affect the surrounding expressions, but it
  s> could be worked around and functionally generalized (again within
  s> specific limitations).

limitations? it is just wrong. that is a char class of all those digits
(and i am not even sure what [6-1] will generate).

uri

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


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

Date: Thu, 21 Apr 2011 06:31:01 +0000 (UTC)
From: Eli the Bearded <*@eli.users.panix.com>
Subject: Re: A regex to search for numeric ranges...
Message-Id: <eli$1104210230@qz.little-neck.ny.us>

In comp.lang.perl.misc, Uri Guttman <uri@StemSystems.com> wrote:
> >>>>> "s" == sln  <sln@netherlands.com> writes:
>   s> /[256-1024]/ is generally possible.
>   s> It has limitations that affect the surrounding expressions, but it
>   s> could be worked around and functionally generalized (again within
>   s> specific limitations).
> 
> limitations? it is just wrong. that is a char class of all those digits
> (and i am not even sure what [6-1] will generate).

Did you look at what he did? He didn't use that exactly char class
but presented two different ways to achieve the goal in an RE --
neither of which look like a good use of an RE, but a fun exercise
I'm sure. The second one, mapping integer sequences to characters to 
then use a Unicode character class has all the workings of a brilliant
bit of obfuscation. I suspect it doesn't scale well, say 2^16 or
2^32, but I don't really know how Perl handles Unicode internally.

Elijah
------
recently presented a method similar to the first of sln's 


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

Date: Thu, 21 Apr 2011 06:28:54 +0200
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 3.8 Is there a pretty-printer (formatter) for Perl?
Message-Id: <210420110628546739%brian.d.foy@gmail.com>

[[ This message was both posted and mailed: see
   the "To," "Cc," and "Newsgroups" headers for details. ]]

In article <966b2$4daf82e7$ad30ae40$30387@news.eurofeeds.com>, Adam
Russell <ac.russell@live.com> wrote:

> Also, there is a pretty good perl plugin for Netbeans
> http://netbeans.mojgorod.ru/perl.html
> that formats perl code within the Netbeans IDE.

I'll see about adding this to the next edition of the FAQ.

Thanks,


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

Date: Thu, 21 Apr 2011 06:07:36 -0500
From: "John Small" <zjsmallz@os2world.net>
Subject: Re: FAQ 4.44 How do I test whether two arrays or hashes are equal?
Message-Id: <4rkzjBzzMnpe-pn2-cgZw1Ivuem8Q@x.y.z>

On Wed, 20 Apr 2011 10:00:01 UTC, PerlFAQ Server 
<brian@theperlreview.com> wrote:
 
> 4.44: How do I test whether two arrays or hashes are equal?

I am new to Perl and, faced with comparing arrays, I came up with:

if ("@array1" eq "@array2") ...

This seems to work for me. But in light of this FAQ posting I have to 
wonder:
1) Are there flaws in the code above?
2) Are there advanatges to the FAQ code below?

> 
>     The following code works for single-level arrays. It uses a stringwise
>     comparison, and does not distinguish defined versus undefined empty
>     strings. Modify if you have other needs.
> 
>             $are_equal = compare_arrays(\@frogs, \@toads);
> 
>             sub compare_arrays {
>                     my ($first, $second) = @_;
>                     no warnings;  # silence spurious -w undef complaints
>                     return 0 unless @$first == @$second;
>                     for (my $i = 0; $i < @$first; $i++) {
>                             return 0 if $first->[$i] ne $second->[$i];
>                             }
>                     return 1;
>                     }


-- 

John Small



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

Date: Thu, 21 Apr 2011 07:36:25 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: FAQ 4.44 How do I test whether two arrays or hashes are equal?
Message-Id: <slrnir08te.uek.tadmc@tadbox.sbcglobal.net>

John Small <zjsmallz@os2world.net> wrote:
> On Wed, 20 Apr 2011 10:00:01 UTC, PerlFAQ Server 
><brian@theperlreview.com> wrote:
>  
>> 4.44: How do I test whether two arrays or hashes are equal?
>
> I am new to Perl and, faced with comparing arrays, I came up with:
>
> if ("@array1" eq "@array2") ...
>
> This seems to work for me. But in light of this FAQ posting I have to 
> wonder:
> 1) Are there flaws in the code above?


Most certainly.

It says that these 2 arrays are equal:

   my @array1 = ('john small', 'john', 'small');
   my @array2 = ('john', 'small', 'john small');

so are these 2, which don't even have the same number of elements:

    my @array1 = ('a b c');
    my @array2 = ('a', 'b', 'c');


> 2) Are there advanatges to the FAQ code below?


It gives the Right Answer, which is a big advantage  :-)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Wed, 20 Apr 2011 20:24:42 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: for @{ my $x } on Perl 5.10 (bug?)
Message-Id: <87wriov1k5.fsf@castleamber.com>

"C.DeRykus" <derykus@gmail.com> writes:

> On Apr 20, 12:53 pm, John Bokma <j...@castleamber.com> wrote:
>> perl -e 'use strict; use warnings; print for @{ my $x }'
>> Can't use an undefined value as an ARRAY reference at -e line 1.
>>
>> This is perl, v5.8.8 built for x86_64-linux-thread-multi
>>
>> perl -e 'use strict; use warnings; print for @{ my $x }'
>>
>> This is perl, v5.10.0 built for x86_64-linux-gnu-thread-multi
>>
>> Is this a known bug? At least, I assume that the latter working is a bug.
>>
>
> Same with 5.12.2:
>
> perl  -Mstrict -wle "print if @{my $x}"
> Can't use an undefined value as an ARRAY reference at -e line 1.
>
> perl  -Mstrict -wle "print for @{my $x}"
>
> At the very least it seems quirky that the
> former fails and the latter doesn't.

Thanks Charles, I've reported it using perlbug.

perl -e'use strict; use warnings; print while @{ my $x };'
Can't use an undefined value as an ARRAY reference at -e line 1.

perl -e'use strict; use warnings; for ( @{ my $x } ) { print }'


-- 
John Bokma                                                               j3b

Blog: http://johnbokma.com/    Facebook: http://www.facebook.com/j.j.j.bokma
    Freelance Perl & Python Development: http://castleamber.com/


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

Date: Thu, 21 Apr 2011 18:35:22 -0600
From: Uno <Uno@example.invalid>
Subject: Re: grabbing a facebook group
Message-Id: <91c0qbFv83U1@mid.individual.net>

On 04/19/2011 01:43 PM, Sherm Pendley wrote:
> Uno<Uno@example.invalid>  writes:
>
>> $ cat fb1.pl
>>   #!/usr/bin/perl
>> use strict;
>>
>> Are you stoned?  Tad, if either being correct or promoting the
>> discussion in c.l.p.misc is part of your job description, I think you
>> need to resign.
>
> "Uno," get a grip. The space before the #! caused the OS to run the file
> as a *shell script*. Once that happened, Perl wasn't involved at all.
>
> I'd like to help you, but you're about one ill-informed rant away from
> being permanently ignored here.
>
> sherm--
>

You know, sherm, I've decided that c.l.p.misc has problems I don't want 
to be a part of.  Thanks for all your help.
-- 
Uno


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

Date: Thu, 21 Apr 2011 22:01:37 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: grabbing a facebook group
Message-Id: <87pqofdoxq.fsf@quad.sysarch.com>

>>>>> "U" == Uno  <Uno@example.invalid> writes:

  U> On 04/19/2011 01:43 PM, Sherm Pendley wrote:
  >> Uno<Uno@example.invalid>  writes:
  >> 
  >>> $ cat fb1.pl
  >>> #!/usr/bin/perl
  >>> use strict;
  >>> 
  >>> Are you stoned?  Tad, if either being correct or promoting the
  >>> discussion in c.l.p.misc is part of your job description, I think you
  >>> need to resign.
  >> 
  >> "Uno," get a grip. The space before the #! caused the OS to run the file
  >> as a *shell script*. Once that happened, Perl wasn't involved at all.
  >> 
  >> I'd like to help you, but you're about one ill-informed rant away from
  >> being permanently ignored here.
  >> 
  >> sherm--
  >> 

  U> You know, sherm, I've decided that c.l.p.misc has problems I don't
  U> want to be a part of.  Thanks for all your help.

please don't let the keyboard smack you on the way out.

you have been one of the dumbest posters here in a very long time. and
that includes quite a few people. you still don't even realize that perl
was never the problem and the space was the problem. until you get that,
you will never learn more coding.

uri

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


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

Date: Thu, 21 Apr 2011 22:37:47 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: grabbing a facebook group
Message-Id: <slrnir1tnh.en.tadmc@tadbox.sbcglobal.net>

Uno <Uno@example.invalid> wrote:

> I've decided that c.l.p.misc has problems I don't want 
> to be a part of.


Yeah.

A place that exposes poseurs makes the poseurs want to leave.

That is the good kind of "problem"!


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Thu, 21 Apr 2011 06:37:12 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Perl RegExp question
Message-Id: <4bb0c37a-8e37-401c-9328-4545222c45ef@r6g2000vbz.googlegroups.com>

On Apr 20, 7:42=A0pm, Ted Zlatanov <t...@lifelogs.com> wrote:
> some_split_function() almost definitely uses regular expressions :)

Yes, it does, but (mostly) I use one of the built in modules, so I
don't have to write it by hand.

> Sure. =A0This works great until %hash gets big. =A0It also produces outpu=
t
> only after all the input is consumed, as opposed to line-based
> processing which tends to be much more responsive.

This does process line by line. It also collects particular datums as
needed. How can you calculate a sum of a datum, or a count, without
collecting the data values? You don't necessarily need all the items
in a line, but for many cases you need to see all the lines before you
can generate your report.

> OK. =A0Many of us do, so I think it's simply that you haven't had the
> opportunity and need to try it, rather than a fundamental shortcoming of
> regular expressions as a data processing and munging tool.

As I said, I use REs regularly, and find them quite useful. I also
find them extremely useful in, for example, vi, where I rely heavily
on REs for various things. I also recognize that REs lie under the
hood of something like, for example, Text::ParseWords or Text::CSV_XS.

I have developed a habit of using the old C-like tools, like substr,
index, etc., when I can, because they seem to lie closer at hand than
an RE. I'm pretty proficient at what I do, so something must work.

CC.


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

Date: Thu, 21 Apr 2011 13:10:20 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: Perl RegExp question
Message-Id: <871v0v327n.fsf@castleamber.com>

ccc31807 <cartercc@gmail.com> writes:

> I have developed a habit of using the old C-like tools, like substr,
> index, etc., when I can, because they seem to lie closer at hand than
> an RE. I'm pretty proficient at what I do, so something must work.

Nothing wrong with that. If I need the last 4 characters, or the first
3, I use substr. If I need to test if a string has a substring, I use
index.

-- 
John Bokma                                                               j3b

Blog: http://johnbokma.com/    Facebook: http://www.facebook.com/j.j.j.bokma
    Freelance Perl & Python Development: http://castleamber.com/


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

Date: Thu, 21 Apr 2011 20:56:17 +0000 (UTC)
From: Eli the Bearded <*@eli.users.panix.com>
Subject: Re: Web Scraping Proxy
Message-Id: <eli$1104211643@qz.little-neck.ny.us>

In comp.lang.perl.misc, Wes Groleau  <Groleau+nntp@FreeShell.org> wrote:
> And that request is failing because FireFox won't allow me
> to accept wsp's SSL certificate.  (Which is presumably a FireFox
> issue, but I wish WSP would keep recording while I fight with FF.)

I've never used the program, but I see in the README file bug list:
        Wsp.pl does not recover from aborted browser requests.
        Do not press stop.  Do not load another page until the
        current page loads completely.

So I think the problem is correctly described by you as a FireFox
issue, compounded by the aborted request bug. I have no problems
getting FireFox to accept various non-conformant certs. I do this
regularly when testing webpages.

Playing with it, it looks like the trick seems to be:

1) Start wsp
2) Try to visit an https site. Firefox will complain about the cert and
   ask you to verify it.
3) Check that wsp is still running, if not restart it.
4) Click on "I understand the risks"
5) Check that wsp is still running, if not restart it.
6) Click on "Add exception"
7) Check that wsp is still running, if not restart it.
8) Go about your business.

Elijah
------
took all of a five minutes to figure that out


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

Date: Thu, 21 Apr 2011 23:01:31 -0400
From: Wes Groleau <Groleau+news@FreeShell.org>
Subject: Re: Web Scraping Proxy
Message-Id: <ioqr28$rci$1@dont-email.me>

On 04-21-2011 16:56, Eli the Bearded wrote:
> In comp.lang.perl.misc, Wes Groleau<Groleau+nntp@FreeShell.org>  wrote:
>> And that request is failing because FireFox won't allow me
>> to accept wsp's SSL certificate.  (Which is presumably a FireFox
>> issue, but I wish WSP would keep recording while I fight with FF.)
>
> I've never used the program, but I see in the README file bug list:
>          Wsp.pl does not recover from aborted browser requests.
>          Do not press stop.  Do not load another page until the
>          current page loads completely.
>
> So I think the problem is correctly described by you as a FireFox
> issue, compounded by the aborted request bug. I have no problems
> getting FireFox to accept various non-conformant certs. I do this
> regularly when testing webpages.

OK, I think you are suggesting that the delay of FF asking me what to do
about the cert is being interpreted by WSP as an "aborted browser 
request" ?  And then the reason I can't get FF to accept the cert is
that the provider of the cert is no longer running?

Sad, but understandable.  Then your suggested workaround also makes 
sense.  Thanks.

Unfortunately, when I turned off the proxy and tried to go to the site 
directly, it demanded I use Internet Explorer only (hard to do on a Mac)
and insisted (falsely) that my caps-lock was on.

-- 
Wes Groleau

   There are two types of people in the world …
   http://Ideas.Lang-Learn.us/barrett?itemid=1157


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

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


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