[27809] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9173 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 19 09:05:48 2006

Date: Wed, 19 Apr 2006 06: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           Wed, 19 Apr 2006     Volume: 10 Number: 9173

Today's topics:
    Re: FAQ 4.44 How do I test whether two arrays or hashes (Anno Siegel)
    Re: RXParse module (by robic0), Version 0.1000 <bik.mido@tiscalinet.it>
    Re: RXParse module (by robic0), Version 0.1000 <bik.mido@tiscalinet.it>
        Term::ReadKey on Win?  5.005 vs 5.8.8? <nospam-abuse@ilyaz.org>
    Re: XS progamming question <bol@adv.magwien.gv.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Apr 2006 09:42:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FAQ 4.44 How do I test whether two arrays or hashes are equal?
Message-Id: <4amevkFttvr2U1@news.dfncis.de>

PerlFAQ Server  <brian@stonehenge.com> wrote in comp.lang.perl.misc:
> This is an excerpt from the latest version perlfaq4.pod, which
> comes with the standard Perl distribution. These postings aim to 
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
> 
> --------------------------------------------------------------------
> 
> 4.44: How do I test whether two arrays or hashes are equal?
> 
>     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;
>         }

The use of "no warnings" in compare_arrays is unnecessarily broad with
modern Perl.  I  suggest to write it:

         sub compare_arrays {
             my ($first, $second) = @_;
             return 0 unless @$first == @$second;
             for (my $i = 0; $i < @$first; $i++) {
                 no warnings 'uninitialized'; # silence spurious complaints
                 return 0 if $first->[$i] ne $second->[$i];
             }
             return 1;
         }

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Wed, 19 Apr 2006 09:40:50 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: RXParse module (by robic0), Version 0.1000
Message-Id: <2upb42pbibik492q5hf3lr7ivuog47n325@4ax.com>

On Mon, 17 Apr 2006 00:27:45 -0400, Uri Guttman <uri@stemsystems.com>
wrote:

>i made a mistake. it uses at least up to $17 which is worse than $14. i
>apologize for that error in my review.

Nitpick: if it's at least up to $17, then it's at least up to $14.
It's not a mistake nor an error: it was an estimate; then you got a
better estimate, period.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 19 Apr 2006 09:56:59 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: RXParse module (by robic0), Version 0.1000
Message-Id: <l5rb42tu0mc129dtf90qj5nnki30sv74jb@4ax.com>

On 17 Apr 2006 08:11:08 GMT, <corff@zedat.fu-berlin.de> wrote:

>: [...] I stay away from it with alchohol and drugs because
>: it reaks my body. It forces my body to [...] hours of creativity that it, my
[snip]
>Take on long distance running. It may help you. It will also keep you away

Possibly related: http://perlmonks.org/?node_id=519362


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 19 Apr 2006 10:11:13 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Term::ReadKey on Win?  5.005 vs 5.8.8?
Message-Id: <e252c1$gvi$1@agate.berkeley.edu>


I'm trying to design a workaround for Perl PerlIO bugs...

Could people with working Term::ReadKey determine what happens on
pressing Enter key (possbly many times, if needed)?  E.g., please run
both

  perl -MTerm::ReadKey -wle "open $in, '+< CONIN$' or die; binmode $in or  die; ReadMode 4, $in; $|=1; print ord while defined($_=getc)"
  perl -MTerm::ReadKey -wle "open $in, '+< CONIN$' or die;
 ReadMode 4, $in; $|=1; print ord while defined($_=getc)"

(one with binmode, another without).  If possible, use pre-5.6 Perl
and one of the current Perls, 5.8.7 and 5.8.8.  Especially interesting
is to know how many Enter keypresses are needed to get "some action",
and how many lines are printed when "an action" happens.

A lot of thanks,
Ilya


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

Date: Wed, 19 Apr 2006 10:10:28 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: XS progamming question
Message-Id: <1145434229.177538@proxy.dienste.wien.at>

Ilya Zakharevich:

>> Ah - you're talking about COPs (shown as 'nextstate' OP in various
>> output) and its "HV* cop_stash" slot, do you? In other words, the
>> package within an OP gets executed, is stored in its preceeding COP?
>> Or, in other words, all "cop_stash" slots within a package point to the
>> same HV?
>
> ... Hard to parse this...

My apologies - English isn't my native language, so maybe it's a little
sloppy...

> Let me try to restate this in "plain" language: the notion of "current
> package" is crucial during compile time.  At run time it is not very
> important - with a few exceptions.  To support these exceptions, and
> to not slow down execution (take into account all these next/last, and
> do not forget goto, they all can easily cross boundaries of packages),
> at compile time the "current package" is stored inside the "cleanup"
> OP, `nextstate'.  (cop_stash - think of it as
cleanup_op_symbol_table_hash).
>
> Is it more clear now?

Yes, I hope so: if a component requires access to the current
package name at runtime (e.g., "caller()"), it can get it by its
preceeding COP, because, at compile time, a pointer to the
package stash is inserted into the COP at offset "cop_stash".

BTW: in my documentation, COP is mentioned as "Comment
Operator".

BTW: will there be substantial changes in XS programming in
Perl 6? If I write a XS module for Perl5, will I have it completly
recoding for Perl6? Are there already some docs for XS
programming in Perl6?

Again, many thanks for your help, and kind greetings,

Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at




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

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


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