[24944] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7194 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 30 06:06:57 2004

Date: Thu, 30 Sep 2004 03:05:11 -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, 30 Sep 2004     Volume: 10 Number: 7194

Today's topics:
        assign a left hand variable to a variable (justme)
    Re: assign a left hand variable to a variable <tore@aursand.no>
    Re: assign a left hand variable to a variable <Graham.T.Wood@oracle.com>
    Re: CGI.pm sticky hidden fields: why? (Randal L. Schwartz)
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
        Explorer doesn't run my perl cgi program like netscape  (Allen)
    Re: Explorer doesn't run my perl cgi program like netsc <thepoet_nospam@arcor.de>
    Re: Explorer doesn't run my perl cgi program like netsc <spamtrap@dot-app.org>
    Re: gather/take <vetro@online.no>
    Re: Help with my regex <shawn.corey@sympatico.ca>
    Re: Newbie: String concatenation limited to 256 charact (Piet)
    Re: Odd sort() problem <mritty@gmail.com>
    Re: Odd sort() problem <spamtrap@dot-app.org>
    Re: Odd sort() problem (Anno Siegel)
        Potential bug ? (kspecial@linuxmail.org)
    Re: Potential bug ? <ebohlman@omsdev.com>
    Re: Precedence of exponentiation <jwkenne@attglobal.net>
    Re: Precedence of exponentiation <bart.lateur@pandora.be>
    Re: process control <Joe.Smith@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 30 Sep 2004 00:44:15 -0700
From: eight02645999@yahoo.com (justme)
Subject: assign a left hand variable to a variable
Message-Id: <c0837966.0409292344.1cf6c0c3@posting.google.com>

hi

how do i assign a left hand side variable to a variable. For example


for($count = 0; $count < @array; $count++  )
{	
 $h = $somevariable->somemethod(args,args);		
}
	
i want to have something like this:

$h0 = $somevariable->somemethod(args,args);
$h1 = $somevariable->somemethod(args,args);
$h3 = $somevariable->somemethod(args,args);
 .....

How to "append" the numbers to $h ? thanks in advance.


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

Date: Thu, 30 Sep 2004 10:37:38 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: assign a left hand variable to a variable
Message-Id: <pan.2004.09.30.08.37.37.788639@aursand.no>

On Thu, 30 Sep 2004 00:44:15 -0700, justme wrote:
> how do i assign a left hand side variable to a variable. For example
> 
> 
> for($count = 0; $count < @array; $count++  )
> {	
>  $h = $somevariable->somemethod(args,args);		
> }
> 	
> i want to have something like this:
> 
> $h0 = $somevariable->somemethod(args,args);
> $h1 = $somevariable->somemethod(args,args);
> $h3 = $somevariable->somemethod(args,args);
> .....
> 
> How to "append" the numbers to $h ? thanks in advance.

You most probably won't do that [1], and you're anyway better off using an
array, as far as I can see;

  for ( 0..$#array ) {
      $h[$_] = ....;
  }


-- 
Tore Aursand <tore@aursand.no>
"Why shouldn't truth be stranger than fiction? Fiction, after all, has
 to make sense." (Mark Twain)


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

Date: Thu, 30 Sep 2004 10:04:59 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: assign a left hand variable to a variable
Message-Id: <415BCC3B.6DB00221@oracle.com>

justme wrote:
> 
> hi
> 
> how do i assign a left hand side variable to a variable. For example
> 
> for($count = 0; $count < @array; $count++  )
> {
>  $h = $somevariable->somemethod(args,args);
> }
> 
> i want to have something like this:
> 
> $h0 = $somevariable->somemethod(args,args);
> $h1 = $somevariable->somemethod(args,args);
> $h3 = $somevariable->somemethod(args,args);
> .....
> 
> How to "append" the numbers to $h ? thanks in advance.

Don't.  Use an array if you just want it indexed with numbers or a hash
if you prefer a string index.

for($count = 0; $count < @array; $count++  )
{
  $h[$count] = $somevariable->somemethod(args,args);
}

You could write something like ...
	$varname = "h$count";
	$$varname = $somevariable->somemethod(args,args);

but that is what's known as a symbolic reference and is generally
frowned upon unless you know what you're doing and have a good reason
for not using a hash or an array.  Symoblic references can lead to the
dreaded "unexpected behaviour".

Graham


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

Date: 29 Sep 2004 19:39:20 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: CGI.pm sticky hidden fields: why?
Message-Id: <1096512502.OcGklmU7mIowOvVbyLCccg@teranews>

>>>>> "wana" == wana  <ioneabu@yahoo.com> writes:

wana> Is there any justification for the 'stickiness' of hidden fields?  A
wana> web page viewer cannot legitimately enter a value into a hidden field,
wana> so why would anyone want to hold over a value to the next page?

It's not really for the *next* page.  It's when you want to redisplay
*this* page because of an error.  It's actually quite good for that.
Good design guidelines say that when you redisplay the current page
with errors flagged that you default to the previous value.  The code
to do that manually would be hard to remember to include, so I'm glad
the default is "sticky".

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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 30 Sep 2004 04:42:49 GMT
From: <jari.aalto <AT> poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1096519341@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto A T poboxes com

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Unix Windows port (for Unix die-hards):
            install http://www.cygwin.com/  which includes native Emacs 21.x.
            and XEmacs port

        o   Pure Native Windows port
            http://www.gnu.org/software/emacs/windows/ntemacs.html
            ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

        o   More Emacs resources at
            http://tiny-tools.sourceforge.net/  => Emacs resource page

Emacs Perl Modules

    Cperl -- Perl programming mode

        http://www.cpan.org/modules/by-authors/id/ILYAZ/cperl-mode/
        http://math.berkeley.edu/~ilya/software/emacs/
        by Ilya Zakharevich

        CPerl is major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

        http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Grep through all Perl manpages (.pod)
        o   Follow POD references e.g. [perlre] to next pod with RETURN
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.

        o   Update `$VERSION' variable with YYYY.MMDD on save.
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Prepare script (version numbering) and Upload it to PAUSE
        o   Generate autoload STUBS (Devel::SelfStubber) for you
            Perl Module (.pm)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in Tiny Tools Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up dattabases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to to do the search, You can adjust
        recursive grep options, set search case sensitivity, add user grep
        options etc.

        You can find latest `igrep.el' module at
        <http://groups.google.com/groups?group=gnu.emacs.sources> The
        maintainer is Jefin Rodgers <kevinr <AT> ihs.com>.

    TinyCompile -- To Browse grep results in Emacs *compile* buffer

        TinyCompile is a minor mode for *compile* buffer from where
        you can collapse unwanted lines or shorten file URLs:

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->

            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: 30 Sep 2004 01:38:31 -0700
From: allen.taylor@halliburton.com (Allen)
Subject: Explorer doesn't run my perl cgi program like netscape does.
Message-Id: <cac1749e.0409300038.35f4bd3e@posting.google.com>

I have a fully tested and functional perl cgi program that works fine
using Netscape. However, when I click on a submit button in Explorer,
nothing happens at all. No logged messages, no error messages. I've
tried searching the internet for some answers but have found nothing
relevant yet. Does anybody have any ideas?
I amusing Netscape 7.1, but this company uses Explorer 6.00. Many
thanks in advance.


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

Date: Thu, 30 Sep 2004 11:30:33 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Explorer doesn't run my perl cgi program like netscape does.
Message-Id: <415bd239$0$8119$9b4e6d93@newsread4.arcor-online.net>

Allen wrote:
> I have a fully tested and functional perl cgi program that works fine
> using Netscape. However, when I click on a submit button in Explorer,
> nothing happens at all. No logged messages, no error messages. I've
> tried searching the internet for some answers but have found nothing
> relevant yet. Does anybody have any ideas?
> I amusing Netscape 7.1, but this company uses Explorer 6.00. Many
> thanks in advance.

Most propably this has nothing to do with perl, but rather with
the HTML form.
Did you check your HTML with http://validator.w3c.org?
Did you test all javascripts in the Document on compatibility?

-Christian


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

Date: Thu, 30 Sep 2004 05:38:32 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Explorer doesn't run my perl cgi program like netscape does.
Message-Id: <Bc-dnc_zAtiFScbcRVn-sw@adelphia.com>

Allen wrote:

> I have a fully tested and functional perl cgi program that works fine
> using Netscape. However, when I click on a submit button in Explorer,
> nothing happens at all. No logged messages, no error messages. I've
> tried searching the internet for some answers but have found nothing
> relevant yet. Does anybody have any ideas?

First of all, are you certain that the problem is Perl-related? Perl 
tends to complain *loudly* when things go wrong, so a failure that 
leaves no traces in the error log is usually a clue to look elsewhere.

Check if the form is being submitted at all - if the CGI never runs, the 
problem is guaranteed to be in the client. If it's in the client, check 
for HTML errors - you *did* validate the HTML, right? And check for 
JavaScript problems, especially if there's form validation or some funky 
onSubmit scripting that could prevent the form from being sent if it's 
buggy.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Thu, 30 Sep 2004 11:35:51 +0200
From: "Vetle Roeim" <vetro@online.no>
Subject: Re: gather/take
Message-Id: <opse4vl1vp3hk3cf@quickfix.opera.com>

On Tue, 28 Sep 2004 14:44:21 +0200, Vetle Roeim <vetro@online.no> wrote:

[...]
>
>    Do you have an example on how to use this?

   Never mind, I found out by myself.

     my @foo = gather {
         for ( @data ) {
             if ( /^a ) {
                 take( $_ );
             }
         }
     };

-- 
It's not a bug, it's the future.


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

Date: Thu, 30 Sep 2004 02:44:49 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Help with my regex
Message-Id: <OWN6d.22063$tT2.1308343@news20.bellglobal.com>

Gunnar Hjalmarsson wrote:
> Or rather
> 
>     /te(\S*?)st/
> 
> I suppose. But it depends of course on what exactly the purpose of the 
> regex is, and I leave it to you to figure out the difference.


Mileage may vary.
	--- Shawn

#!/usr/bin/perl

use strict;
use warnings;

use Benchmark;

my @tests = (
   "test",
   "te st",
   "teXst",
   "te         st",
   "teXXXXXXXXXst",
   "te\xA0st",
   "te\tst",
   'te' . ( ' ' x 1_000 ) . 'st',
   'te' . ( 'X' x 1_000 ) . 'st',
);

for my $s ( @tests ){
   print "Testing $s\n";
   timethese( 1_000_000, {
     'greedy \S* ' => sub { $s =~ /te(\S*)st/; },
     'frugal \S*?' => sub { $s =~ /te(\S*?)st/; },
   });
   print "\n";
}

__END__

Testing test
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?:  3 wallclock secs ( 2.92 usr +  0.00 sys =  2.92 CPU) @ 
342465.75/s (n=1000000)
greedy \S* :  3 wallclock secs ( 3.27 usr +  0.00 sys =  3.27 CPU) @ 
305810.40/s (n=1000000)

Testing te st
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?:  2 wallclock secs ( 1.76 usr +  0.00 sys =  1.76 CPU) @ 
568181.82/s (n=1000000)
greedy \S* :  2 wallclock secs ( 1.75 usr +  0.00 sys =  1.75 CPU) @ 
571428.57/s (n=1000000)

Testing teXst
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?:  3 wallclock secs ( 3.09 usr +  0.00 sys =  3.09 CPU) @ 
323624.60/s (n=1000000)
greedy \S* :  3 wallclock secs ( 3.21 usr +  0.00 sys =  3.21 CPU) @ 
311526.48/s (n=1000000)

Testing te         st
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?:  2 wallclock secs ( 1.89 usr +  0.00 sys =  1.89 CPU) @ 
529100.53/s (n=1000000)
greedy \S* :  2 wallclock secs ( 1.84 usr +  0.00 sys =  1.84 CPU) @ 
543478.26/s (n=1000000)

Testing teXXXXXXXXXst
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?:  4 wallclock secs ( 3.35 usr +  0.00 sys =  3.35 CPU) @ 
298507.46/s (n=1000000)
greedy \S* :  3 wallclock secs ( 3.39 usr +  0.00 sys =  3.39 CPU) @ 
294985.25/s (n=1000000)

Testing te�st
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?:  3 wallclock secs ( 3.19 usr +  0.00 sys =  3.19 CPU) @ 
313479.62/s (n=1000000)
greedy \S* :  4 wallclock secs ( 3.21 usr +  0.00 sys =  3.21 CPU) @ 
311526.48/s (n=1000000)

Testing te      st
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?:  1 wallclock secs ( 1.73 usr +  0.00 sys =  1.73 CPU) @ 
578034.68/s (n=1000000)
greedy \S* :  2 wallclock secs ( 1.75 usr +  0.00 sys =  1.75 CPU) @ 
571428.57/s (n=1000000)

Testing te 
 
 
 
 
 
 
 
 
 
 
 
 
 
                st
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?: 19 wallclock secs (18.35 usr +  0.00 sys = 18.35 CPU) @ 
54495.91/s (n=1000000)
greedy \S* :  5 wallclock secs ( 5.87 usr +  0.00 sys =  5.87 CPU) @ 
170357.75/s (n=1000000)

Testing 
teXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXst
Benchmark: timing 1000000 iterations of frugal \S*?, greedy \S* ...
frugal \S*?: 32 wallclock secs (31.42 usr +  0.00 sys = 31.42 CPU) @ 
31826.86/s (n=1000000)
greedy \S* : 19 wallclock secs (18.75 usr +  0.00 sys = 18.75 CPU) @ 
53333.33/s (n=1000000)


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

Date: 29 Sep 2004 23:11:06 -0700
From: pit.grinja@gmx.de (Piet)
Subject: Re: Newbie: String concatenation limited to 256 characters?
Message-Id: <39cbe663.0409292211.5661f28e@posting.google.com>

pit.grinja@gmx.de (Piet) wrote in message news:<39cbe663.0409290921.1f67d3f9@posting.google.com>...
> Hello,
> I have written a small script that parses an (ugly) HTML file line by
> line and converts the relevant information to CSV. During parsing, I
> heavily use string concatenation to glue together parts of text that
> belong together (but might be separated in the original file by tags
> or newlines). In the code, the expression
> $oldstring = $oldstring.$newstring
> occurs very often.
> Frequently, the strings get longer than 256 characters. At this point,
> the string concatenation refuses to add anything to $oldstring. How is
> it possible to avoid that?
> Thanks in advance for answers on  a (maybe very newbish) question
Thanks for all your comments. In fact, the problem was, of course, NOT
perl. How could it... My fault was that I didn´t check the original
text output file of the parsing, only the contents that survived
importing the text file into M$e...l.
I apologize for that.
Piet


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

Date: Wed, 29 Sep 2004 22:59:41 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Odd sort() problem
Message-Id: <cjfsra$c15$1@misc-cct.server.rpi.edu>

Sid Norman wrote:

> "Paul Lalli" <mritty@gmail.com> wrote in message
> news:zNE6d.17368$M45.9624@trndny09...
> 
>>"187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
>>
>>>Paul Lalli wrote:
>>>
>>>>"187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
>>>>
>>>But shouldn't it be complaining either that lc{ } is an undefined
>>>hash or lc being a bareword?
>>
>>Of course not.  lc is a built in function.  it's taking whatever comes
>>after "lc" as the parameter you're passing to lc. In this case, what
>>follows is an anonymous hash, signified by the { }
> 
> 
> Actually lc{ } should be seen as a named block, according to PerlDoc.
> This is indeed a broken occurance, and should be reported.

Can you be more specific?  What perldoc section is this in?  I'd be most 
interested in seeing it.

Paul Lalli


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

Date: Thu, 30 Sep 2004 00:19:47 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Odd sort() problem
Message-Id: <_5GdnYHEtPX5FMbcRVn-gg@adelphia.com>

Sid Norman wrote:

> No, it's actually more like
> 
> lc{
>   a;
> }
> 
> It's a named block.

No it's not. The label for a named block requires a ':'.

lc: {
     a;
}

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 30 Sep 2004 07:27:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Odd sort() problem
Message-Id: <cjgcgr$311$1@mamenchi.zrz.TU-Berlin.DE>

Sid Norman <i.hate.spam.savagebeaste@yahoo.com> wrote in comp.lang.perl.misc:
> "Paul Lalli" <mritty@gmail.com> wrote in message
> news:zNE6d.17368$M45.9624@trndny09...
> > "187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
> > > Paul Lalli wrote:
> > > > "187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
> > > >> A. Sinan Unur wrote:
> > > >>> "187" <bigal187@invalid.rx.eastcoasttfc.com> wrote
> > > >>
> > > >> But what I really don't understand is why it doesn't result in a
> > > >> compile error? lc{$a}, one would think, is not a valid statement.
> > > >
> > > > The warning below answers this question.
> > >
> > > But shouldn't it be complaining either that lc{ } is an undefined
> hash
> > > or lc being a bareword?
> >
> > Of course not.  lc is a built in function.  it's taking whatever comes
> > after "lc" as the parameter you're passing to lc. In this case, what
> > follows is an anonymous hash, signified by the { }
> 
> Actually lc{ } should be seen as a named block, according to PerlDoc.
> This is indeed a broken occurance, and should be reported.

You don't know what you're talking about.

Anno


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

Date: 29 Sep 2004 18:08:01 -0700
From: kspecial@linuxmail.org (kspecial@linuxmail.org)
Subject: Potential bug ?
Message-Id: <365f784f.0409291708.37da61d7@posting.google.com>

Hey, i've got some code here that i've been having problems with, I
have crunched my brain and have resorted to this very place. For some
reason the variable @logins in the following code is being undefined
when there is absolutely nothing that is using @logins in such a way
that it would be undefined, the two functions are out of a lot longer
bit of code but I have put them together here in such a manor that you
can run the following code yourself as a file and get an eye to what's
going on, please excuse any bad syntax, unless it's having to do with
something i've done wrong that causes this problem. Here is the code:

--- CODE ---

@logins = ('K-sPecial perl.freak o (kspecial)');

logout_user(\@logins, "K-sPecial",
"d41d8cd98f00b204e9800998ecf8427e");

sub logout_user {
        my ($logins, $name, $pass) = @_;
        print "Logins ($logins) in logout_user: @$logins\r\n";
        foreach (@$logins) {
                if (m/^\s*$name\s+/i) {
                        #my $rname = get_rname($logins, "$name", ' ',
1);
                        my $md5 = ub_value ("$rname", 1);
                        print "Now logins ($logins) in logout_user:
@$logins\r\n";
                        print "Got $rname and $name then $md5 and
$pass\r\n";
                        if ("$pass" eq "$md5") {
                                #my $return = del_login($logins,
"$name");
                                return ($return);
                        }
                }
                return(0);
        }
}

sub ub_value {
        my ($user, @values) = @_;
        #$user = rem_re($user);
        my $userline;
        open (FH, "<fool.txt") or return (undef);
        while (<FH>) {
                $userline = $_ if m/^$user:/i;
        }
        close(FH);
        print "Userline is $userline";
        if ($userline) {
                my @results;
                foreach(@values) {
                        push(@results, (split(':', "$userline"))[$_]);
                }
                print "Gots the @results\r\n";
                return ("$results[0]") if scalar(@values) == 1;
                return("@results");
        }
        else {  
                print "returning 0\r\n";
                return(0);
        }
}

--- END CODE ---

So i'm going to run that code exactly as is and show you it's output:

--- OUTPUT ---

kspecial@xzziroz:~$ perl borked.pl
Logins (ARRAY(0x814490c)) in logout_user: K-sPecial perl.freak o
(kspecial)
Userline is returning 0
Now logins (ARRAY(0x814490c)) in logout_user: 
Got  and K-sPecial then 0 and d41d8cd98f00b204e9800998ecf8427e

--- END OUTPUT ---

Look! @logins is completely being undefined with no apparent reason!
Now try taking out the call to ub_value ( my $md5 = ub_value
("$rname", 1); ) now @logins is fine. It prints this:

--- OUTPUT ---
kspecial@xzziroz:~$ perl borked.pl
Logins (ARRAY(0x814490c)) in logout_user: K-sPecial perl.freak o
(kspecial)
Now logins (ARRAY(0x814490c)) in logout_user: K-sPecial perl.freak o
(kspecial)
Got  and K-sPecial then  and d41d8cd98f00b204e9800998ecf8427e

--- END OUTPUT ---

Just as it should... now i'm not very good with the perl debugger but
I did manage to get a glimpse at what was happening, at the user
level.

Here is the debugging: 

--- DEBUGGING ---
main::ub_value(borked.pl:24):           my ($user, @values) = @_;
  DB<3> s
main::ub_value(borked.pl:26):           my $userline;
  DB<3> p "@logins"
K-sPecial perl.freak o (kspecial)
  DB<4> s
main::ub_value(borked.pl:27):           open (FH, "<fool.txt") or
return (undef);
  DB<4> p "@logins"
K-sPecial perl.freak o (kspecial)
  DB<5> s
main::ub_value(borked.pl:28):           while (<FH>) {
  DB<5> p "@logins"
K-sPecial perl.freak o (kspecial)
  DB<6> s
main::ub_value(borked.pl:29):                   $userline = $_ if
m/^$user:/i;
  DB<6> p "@logins"
kspecial:d41d8cd98f00b204e9800998ecf8427e:ow:-1:::
  DB<7> s
main::ub_value(borked.pl:29):                   $userline = $_ if
m/^$user:/i;
  DB<7> p "@logins"
xemp:c4ca4238a0b923820dcc509a6f75849b:o:1000:::
  DB<8> s
main::ub_value(borked.pl:29):                   $userline = $_ if
m/^$user:/i;
  DB<8> p "@logins"
coprime:c81e728d9d4c2f636f067f89cc14862c:v:9999:::

--- END DEBUGGING ---

Of course that's assuming your fool.txt looks like this: 

--- START fool.txt ---
kspecial:d41d8cd98f00b204e9800998ecf8427e:ow:-1:::
xemp:c4ca4238a0b923820dcc509a6f75849b:o:1000:::
coprime:c81e728d9d4c2f636f067f89cc14862c:v:9999:::
--- END fool.txt ---

Oddly the line " $userline = $_ if m/^$user:/i " is assigning $_ to
@logins on every loop......I'm gonig to also send this same message
using 'perlbug' if i'm able to.

--K-sPecial


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

Date: 30 Sep 2004 02:01:13 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Potential bug ?
Message-Id: <Xns9573D6B6B4488ebohlmanomsdevcom@130.133.1.4>

kspecial@linuxmail.org (kspecial@linuxmail.org) wrote in 
news:365f784f.0409291708.37da61d7@posting.google.com:

> Hey, i've got some code here that i've been having problems with, I
> have crunched my brain and have resorted to this very place. For some
> reason the variable @logins in the following code is being undefined
> when there is absolutely nothing that is using @logins in such a way
> that it would be undefined, the two functions are out of a lot longer

Actually, there is.

> @logins = ('K-sPecial perl.freak o (kspecial)');
> 
> logout_user(\@logins, "K-sPecial",
> "d41d8cd98f00b204e9800998ecf8427e");
> 
> sub logout_user {
>         my ($logins, $name, $pass) = @_;
>         print "Logins ($logins) in logout_user: @$logins\r\n";
>         foreach (@$logins) {

Throughout this loop $_ will be an *alias* to the appropriate element of 
@logins.  That means, _inter alia_, that any assignment to $_ within 
the loop will change the corresponding element of @logins.

>                 if (m/^\s*$name\s+/i) {
>                         #my $rname = get_rname($logins, "$name", ' ',
> 1);
>                         my $md5 = ub_value ("$rname", 1);
>                         print "Now logins ($logins) in logout_user:
> @$logins\r\n";
>                         print "Got $rname and $name then $md5 and
> $pass\r\n";
>                         if ("$pass" eq "$md5") {
>                                 #my $return = del_login($logins,
> "$name");
>                                 return ($return);
>                         }
>                 }
>                 return(0);
>         }

So far we haven't seen anything *directly* affecting $_, but there were a 
bunch of sub calls...

> }
> 
> sub ub_value {
>         my ($user, @values) = @_;
>         #$user = rem_re($user);
>         my $userline;
>         open (FH, "<fool.txt") or return (undef);
>         while (<FH>) {

OOPS!  Remember that $_ is *not* automatically localized during sub calls, 
so each line read is overwriting an element of @logins.  And, of course, 
the very last read will put undef there.

>                 $userline = $_ if m/^$user:/i;
>         }
>         close(FH);
>         print "Userline is $userline";
>         if ($userline) {
>                 my @results;
>                 foreach(@values) {

Here $_ is actually being localized, so no further trashing is going on.

>                         push(@results, (split(':', "$userline"))[$_]);
>                 }
>                 print "Gots the @results\r\n";
>                 return ("$results[0]") if scalar(@values) == 1;
>                 return("@results");
>         }
>         else {  
>                 print "returning 0\r\n";
>                 return(0);
>         }
> }

Moral of the story: if you need to loop over an array or list and you're 
going to be doing something non-trivial (such as calling subs) in the loop, 
use an explicit lexical ("my") loop variable rather than implicitly using 
$_ (which, being a global variable, has all the problems associated with 
global variables).



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

Date: Thu, 30 Sep 2004 02:16:06 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Precedence of exponentiation
Message-Id: <G%J6d.11382$kq6.5568448@news4.srv.hcvlny.cv.net>

Anno Siegel wrote:
> Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> 
> [...]
> 
> 
>>I agree that it would have been better if Perl parsed -a ** b as 
>>(-a) ** b, but...
> 
> 
> I disagree.  Traditional mathematics construes -x as (-1) * x, and
> consequently -a ** b = (-1) * (a ** b) = -(a ** b), because ** binds
> tighter than *.  Most computer languages follow suit.

Or else say that unary minus binds the same as **, but that they read 
from right to left (which also solves the a ** b ** c problem).

-- 
John W. Kennedy
"Compact is becoming contract,
Man only earns and pays."
   -- Charles Williams.  "Bors to Elayne:  On the King's Coins"


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

Date: Thu, 30 Sep 2004 06:33:23 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Precedence of exponentiation
Message-Id: <33anl0tjhg1rdkeivs5ucv1nrf2uibika9@4ax.com>

José Luis Pérez Diez wrote:

>In article <1096260839.GO/RR5PNg+xP+vWX0dEBRg@teranews>, David Frauzel 
>wrote:
>> Am I really in the minority in thinking that -2**4 should mean (-2)**4?
>>
>
>What shold 4-2**4 mean? 

You are confusing the two types of minus sign uses: 1) as a unary sign,
2) as a replacement for "+" in addition, i.e. in subtraction

	-2**4

is unary minus.

	4-2**4

is subtraction.

-- 
	Bart.


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

Date: Thu, 30 Sep 2004 08:54:52 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: process control
Message-Id: <sRP6d.181082$3l3.22193@attbi_s03>

Matt wrote:

> command1
> command2
> perlscript.pl
> 
> However, when I try to integrate command1 and command2 into perlscript.pl 
> using
> 
> system("command1");
> system("command2");
> 
> it doesn't work.

It works just fine, as long as command1 and command2
   1) are recognized by /bin/sh (i.e. not a csh alias)
   2) don't set environment variables, current working directory,
      or any other shell-internal settings.

If the commands do affect internal shell settings (such as
"export PATH=..."), you'll have to perform the equivalent
without using system().
	-Joe


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

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


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