[32327] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3594 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 19 09:09:29 2012

Date: Thu, 19 Jan 2012 06:09:10 -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           Thu, 19 Jan 2012     Volume: 11 Number: 3594

Today's topics:
        [style] parsing name=value lists (Seymour J.)
    Re: How to remove STDIN in perl CGI <hslee911@yahoo.com>
        lib::libXML parsing comments (Fergus McMenemie)
    Re: search.cpan.org: how to advice its displays <davidp@preshweb.co.uk>
    Re: Single-File Inheritance <davidp@preshweb.co.uk>
    Re: Single-File Inheritance <jimsgibson@gmail.com>
    Re: Single-File Inheritance <jimsgibson@gmail.com>
    Re: Single-File Inheritance <jimsgibson@gmail.com>
    Re: Single-File Inheritance <ben@morrow.me.uk>
    Re: Single-File Inheritance (Seymour J.)
    Re: ssh tunnel <nospam@lisse.NA>
    Re: Unicode-AGE of a character? <helmut@wollmersdorfer.at>
    Re: When is @_ undefined? (Tim McDaniel)
    Re: When is @_ undefined? <rweikusat@mssgmbh.com>
    Re: When is @_ undefined? <ben@morrow.me.uk>
    Re: When is @_ undefined? <ben@morrow.me.uk>
    Re: When is @_ undefined? (Seymour J.)
    Re: When is @_ undefined? <NoSpamPleaseButThisIsValid3@gmx.net>
    Re: When is @_ undefined? (Seymour J.)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 19 Jan 2012 07:32:31 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: [style] parsing name=value lists
Message-Id: <4f180d5f$3$fuzhry+tra$mr2ice@news.patriot.net>

I want to write some code that will retrieve TXT records containing
name=value pairs, separated by commas. I'm only interested in specific
names. The obvious was to do this is something like

my $rr;
my %names={r=>1, ro=>1};
my %opt;
for my $pair (split /;/ $rr) {
    if (/\s*(\w+)=(\w+)\s*$/) {
      if ($names{$1})
        $opt{$1}=$2;
      }
    } else {
      print STDERR, "invalid option $pair\n"; 
    }
}

but that looks awkward. Is there a better style?

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Wed, 18 Jan 2012 17:00:23 -0800 (PST)
From: James <hslee911@yahoo.com>
Subject: Re: How to remove STDIN in perl CGI
Message-Id: <8e1cadb5-f06f-41c8-a544-d859daef9e95@j15g2000yqb.googlegroups.com>

On Jan 18, 1:07=A0am, Justin C <justin.1...@purestblue.com> wrote:
> On 2012-01-17, James <hslee...@yahoo.com> wrote:
>
> > How to remove STDIN string in perl CGI (post method) once it is
> > processed? Is it possible?
> > The goal is, if the browser is refreshed, the STDIN string no longer
> > affects the outcome.
>
> I'm not certain what it is you mean, but it sounds like one of these may
> be the answer.
>
> use CGI qw/:standard -nosticky/;
> (fields don't remember their previous value)
>
> $query->delete('foo','bar','baz');
> clears the named parameters.
>
> 'perldoc CGI' will help with both of these.
>
> If I'm wrong, please try to explain better what you mean, or, as Ben has
> said, provide an example.
>
> =A0 =A0Justin.
>
> --
> Justin C, by the sea.

Thanks all. I will try and let you know.
By the way, use CGI and read(STDIN, $buffer, ...) do not seem to work
together.
I need to read perldoc CGI.

James


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

Date: Thu, 19 Jan 2012 10:49:40 +0000
From: fergus@twig-me-uk.not.here (Fergus McMenemie)
Subject: lib::libXML parsing comments
Message-Id: <1ke44yq.2ckot41ttw044N%fergus@twig-me-uk.not.here>

hi,

I have to parse an XML document and rewrite it, after sorting some of
the nodes. Some of these nodes have assocated comments which I have been
told have to remain beside their node.

However walking the list of nodes returned by XML::LibXML's
getChildNodes or childNodes I never see XML_COMMENT_NODE returned. It
looks as though the parser is discarding comments.

perl : v5.8.8
XML::LibXML : 1.7

Comments please:-)


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

Date: Wed, 18 Jan 2012 19:28:04 +0000
From: David Precious <davidp@preshweb.co.uk>
Subject: Re: search.cpan.org: how to advice its displays
Message-Id: <20120118192804.762c2cbc@columbia>

On Wed, 11 Jan 2012 08:13:05 +0000 (UTC)
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:

> I think that search.cpan.org is one of the largests and most useful
> contributions to the Perl community.  I use it very often, and do not
> know anything comparably magnificent in other endevoirs - and not only
> programming endevoirs.

Consider also https://metacpan.org/ if you haven't used it yet.


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

Date: Wed, 18 Jan 2012 19:33:13 +0000
From: David Precious <davidp@preshweb.co.uk>
Subject: Re: Single-File Inheritance
Message-Id: <20120118193313.3198727a@columbia>

On Tue, 17 Jan 2012 17:08:50 -0800
Jim Gibson <jimsgibson@gmail.com> wrote:

> package ConfigFile;
> our @ISA = qw( DataFile );

Rather than manually stuff @ISA, I'd use 'parent' with the -norequire
option:

    package ConfigFile;
    use parent -norequire DataFile;
    ...





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

Date: Wed, 18 Jan 2012 15:55:04 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Single-File Inheritance
Message-Id: <180120121555041858%jimsgibson@gmail.com>

In article <20120117203145.805$rp@newsreader.com>, <xhoster@gmail.com>
wrote:

> Jim Gibson <jimsgibson@gmail.com> wrote:
> >
> > % cat single.pl
> > #!/usr/local/bin/perl
> > use strict;
> > use warnings;
> >
> > my $file = ConfigFile->new();    # line 5
> >
> ....
> >
> > package ConfigFile;
> > our @ISA = qw( DataFile );
> 
> > % perl single.pl
> > Can't locate object method "new" via package "ConfigFile" at single.pl
> > line 5.
> 
> The creation of the @ISA alias occurs at compile time (I think), but the
> assignment to @ISA happens only at run time when that line is encountered.
> 
> At the time line 5 is executed, the ISA assignment line has not yet
> be run in the runtime, so has not yet taken place and @ISA is empty.
> 
> You can wrap the @ISA assignment in a BEGIN block to force it to happen at
> compile time, or you can move your main code to be below the package code.

Thanks for the explanation. That works.

-- 
Jim Gibson


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

Date: Wed, 18 Jan 2012 16:19:57 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Single-File Inheritance
Message-Id: <180120121619571440%jimsgibson@gmail.com>

In article <4f16d2bb$5$fuzhry+tra$mr2ice@news.patriot.net>, Seymour J.
<spamtrap@library.lspace.org.invalid> wrote:

> In <170120121708505710%jimsgibson@gmail.com>, on 01/17/2012
>    at 05:08 PM, Jim Gibson <jimsgibson@gmail.com> said:
> 
> >I am trying to do the Right Thing and write a data-processing program
> >using lofty Object-Oriented principles, instead of my usual lazy
> >procedural ways,
> 
> You have to carve the bird at the joints.
> 
> >I am trying to read some data files that have the same format in the
> >first 6 lines, then have different data records in subsequent lines.
> >I thought I would write a parent class that reads the header lines,
> >then child classes to read and parse subsequent lines.
> 
> Why? Why not a generic parent class and child classes for header lines
> and for each category inferred from the header? 

I think that is what I am trying to do. Perhaps I could explain it
better by saying "write a parent class that has methods to read the
header lines, and child classes that have specialized methods to read
and parse subsequent lines." File category is actually derived from the
file name, not the contents of the header lines.

> 
> >my $file = ConfigFile->new();    # line 5
> 
> Shouldn't that be
> 
> my $file = DataFile->new();    # line 5

I don't think so. DataFile is the parent class and doesn't have any
methods to interpret the data. ConfigFile is a child class that reads
and parses config files (in this simple, made-up example). I won't ever
instantiate an object of the DataFile class. I will instantiate a
ConfigFile object and call new() and open() methods on that object,
which will cause DataFile::new() and DataFile::open() to be called,
since ConfigFile inherits new() and open() from DataFile.

> 
> >If I put the packages in separate files, it works (compiles and
> >runs).
> 
> Could yuou show skeletal versions of the individual files?

The contents of the files are irrelevant for my problem, which happens
before the files are opened. But thanks.

-- 
Jim Gibson


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

Date: Wed, 18 Jan 2012 16:26:22 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Single-File Inheritance
Message-Id: <180120121626224543%jimsgibson@gmail.com>

In article <20120118193313.3198727a@columbia>, David Precious
<davidp@preshweb.co.uk> wrote:

> On Tue, 17 Jan 2012 17:08:50 -0800
> Jim Gibson <jimsgibson@gmail.com> wrote:
> 
> > package ConfigFile;
> > our @ISA = qw( DataFile );
> 
> Rather than manually stuff @ISA, I'd use 'parent' with the -norequire
> option:
> 
>     package ConfigFile;
>     use parent -norequire DataFile;
>     ...

Thanks. This works:

    use parent -norequire, 'DataFile';

although I don't see any advantage over 'our @ISA = ...'

-- 
Jim Gibson


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

Date: Thu, 19 Jan 2012 01:48:48 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Single-File Inheritance
Message-Id: <0d9ku8-ijk2.ln1@anubis.morrow.me.uk>


Quoth Jim Gibson <jimsgibson@gmail.com>:
> In article <20120118193313.3198727a@columbia>, David Precious
> <davidp@preshweb.co.uk> wrote:
> > 
> > Rather than manually stuff @ISA, I'd use 'parent' with the -norequire
> > option:
> > 
> >     package ConfigFile;
> >     use parent -norequire DataFile;
> >     ...
> 
> Thanks. This works:
> 
>     use parent -norequire, 'DataFile';
> 
> although I don't see any advantage over 'our @ISA = ...'

It is, by design, equivalent to

    BEGIN { our @ISA = "DataFile" }

and the fact the assignment happens at compile time can be important.

For the few circumstances where keeping a class in the 'wrong' file is a
good idea, I wouldn't bother with 'parent' and would just use the BEGIN
above. 'parent' is useful in the normal case, where you need to load the
parent class as well as inherit from it.

Ben



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

Date: Wed, 18 Jan 2012 22:30:41 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: Single-File Inheritance
Message-Id: <4f178e61$4$fuzhry+tra$mr2ice@news.patriot.net>

In <180120121619571440%jimsgibson@gmail.com>, on 01/18/2012
   at 04:19 PM, Jim Gibson <jimsgibson@gmail.com> said:

>I think that is what I am trying to do. 

No.

>Perhaps I could explain it better 

That's what you wrote the first time; it's not what I'm suggesting.

>by saying "write a parent class that has methods to read the
>header lines, and child classes that have specialized methods to read
>and parse subsequent lines."

Why not have the methods for header lines in child classes?

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Thu, 19 Jan 2012 06:50:43 +0200
From: Dr Eberhard W Lisse <nospam@lisse.NA>
Subject: Re: ssh tunnel
Message-Id: <4F17A123.8010008@lisse.NA>

Peter,

reason for failure:

	Stupidity and Ignorance of this elderly Gynaecologist :-)-O

I have the key pairs organized :-)-O

el

On 2012-01-17 12:17 , Peter Makholm wrote:
> Dr Eberhard W Lisse <nospam@lisse.NA> writes:
> 
>>> maybe I misunderstand the problem, but have you tried
>>> simply starting ssh in the background (with open or
>>> fork/exec) at the start of your script and killing it at
>>> the end?
>>
>> Haven't been able to successfully do that.
> 
> What did you try? How did it fail?
> 
>> Have you got a working code fragment?
> 
> I have written a lot of code which rather naïvely uses
> IPC::Open3 to run ssh as a background process.  It should
> work for opening a tunnel.
> 
> The problems I don't usual handle is that the initial
> connection often asks whether to accept the host key.  In
> this scenario the process just hangs.  If you just accept
> the hostkey by hand it works correctly.
> 
> //Makholm
> 


-- 
If you want to email me, replace nospam with el


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

Date: Wed, 18 Jan 2012 22:11:48 +0100
From: Helmut Wollmersdorfer <helmut@wollmersdorfer.at>
Subject: Re: Unicode-AGE of a character?
Message-Id: <jf7cil$24pk$1@geiz-ist-geil.priv.at>

On 01/10/2012 07:47 AM, Ilya Zakharevich wrote:
> I looked through the docs I could find, and can't find any way to
> determine the "Unicode AGE" of a particular codepoint except for:
>
>    a) running /\p{Present_in: FOO}/ for all forseeable values of FOO;

If you want to know the AGE then you should match the Age property;-)

$ perl -E 'say "matches" if ("\x{0514}" =~ m/\p{Age=5.1}/)'
matches

>    b) manually parsing $out = do 'unicore/To/Age.pl';.

Or write a better Unicode::UCD module.
I really wanted to do this, because Unicode::UCD does not use the 
original UCD--it also uses unicore.

> Do I miss anything?

You can install Unicode::Tussle from CPAN. It provides some scripts.

Examples:

$ perl /usr/local/bin/unichars '\p{Age=6.0}' '\p{Cyrillic}' | cat
  Ô¦  U+0526 CYRILLIC CAPITAL LETTER SHHA WITH DESCENDER
  Ô§  U+0527 CYRILLIC SMALL LETTER SHHA WITH DESCENDER
  ê™   U+A660 CYRILLIC CAPITAL LETTER REVERSED TSE
  ꙡ  U+A661 CYRILLIC SMALL LETTER REVERSED TSE

$ time perl /usr/local/bin/uniprops -au U+0526 | grep -P '(Age|Pre)'
     Age=6.0 Bidi_Class=L Bidi_Class=Left_To_Right BC=L 
Block=Cyrillic_Supplement Block=Cyrillic_Supplementary
        Numeric_Value=NaN NV=NaN Present_In=6.0 IN=6.0 SC=Cyrl 
Script=Cyrl Sentence_Break=UP Sentence_Break=Upper SB=UP

real	0m1.380s
user	0m1.352s
sys	0m0.040s

You see, that's very famous information, but it's very slow.

Another disadvantage of uniprops is that it also uses unicore-files and 
thus depends on perl-5.14 (more or less). 5.10 misses many properties in 
unicore.

IMHO you want something what I am also missing:

use Unicode::Properties;

my $u = Unicode::Properties->new();

my $age 	= $u->get_property($char, 'Age');
my $script 	= $u->get_property($char, 'Script');

Helmut Wollmersdorfer


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

Date: Wed, 18 Jan 2012 19:32:34 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: When is @_ undefined?
Message-Id: <jf76oi$bto$1@reader1.panix.com>

In article <mmdju8-fme2.ln1@anubis.morrow.me.uk>,
Ben Morrow  <ben@morrow.me.uk> wrote:
>No, a comma is always the comma operator. In list context it builds a
>list, in scalar context it returns its RH argument.

As a tangent, is it more correct to say "a LIST in a scalar context
evaluates to its length" or "an ARRAY in a scalar context evaluates to
its length"?  I think there's a subtle distinction in Perl between
"array" and "list" but I'm don't know the details.

>It's not fundamentally different from any other operator with list
>and scalar versions, as you can see from
>    sub foo { return 1, 2, 3; }
>    say foo;
>    say scalar foo;

Not the best example, because I couldn't tell whether "scalar foo" was
evaluating to the last element or the length of the list.

    #! /usr/bin/perl
    sub foo { return 19, 18, 17; }
    print foo, "\n";
    print scalar foo, "\n";
    exit 0;

prints 17.

Though even then, someone might think foo returns a list regardless,
and the caller might be the one who "makes it a comma operator".
A clearer example might be

    #! /usr/bin/perl
    sub foo { return localtime; }
    print foo, "\n";
    print scalar foo, "\n";
    exit 0;

printing something like

    5727141801123170
    Wed Jan 18 14:27:57 2012

Or "return 17..19", or something else that does something different
based on its context.

>[leaving aside "func indirect args,...] a method call is always one
>of
>
>    $o->proto(3), 5, "\n";
>    $o->noproto(3, 5, "\n");
>
>with no ambiguity about which arguments go to the method and which
>don't. This would mean deferring the prototype check to runtime, of
>course, at which point we're back to there being very little
>advantage of ($$$$$$$) over '@_ == 7 or die'.

Except arguably ease, clarity, having a standard message as opposed to
a user-devised one ... and having prototypes work everywhere and
consistently.

-- 
Tim McDaniel, tmcd@panix.com


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

Date: Wed, 18 Jan 2012 19:45:34 +0000
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: When is @_ undefined?
Message-Id: <8762g894m9.fsf@sapphire.mobileactivedefense.com>

tmcd@panix.com (Tim McDaniel) writes:
> In article <mmdju8-fme2.ln1@anubis.morrow.me.uk>,
> Ben Morrow  <ben@morrow.me.uk> wrote:
>>No, a comma is always the comma operator. In list context it builds a
>>list, in scalar context it returns its RH argument.
>
> As a tangent, is it more correct to say "a LIST in a scalar context
> evaluates to its length" or "an ARRAY in a scalar context evaluates to
> its length"?  I think there's a subtle distinction in Perl between
> "array" and "list" but I'm don't know the details.

In scalar context, a list evaluates to its last element.

[rw@sapphire]/tmp $perl -e 'print scalar(qw(a b c)), "\n";'
c


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

Date: Wed, 18 Jan 2012 22:37:48 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: When is @_ undefined?
Message-Id: <s6uju8-tlh2.ln1@anubis.morrow.me.uk>


Quoth Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>:
> In <7klhu8-5g22.ln1@anubis.morrow.me.uk>, on 01/18/2012
>    at 01:59 AM, Ben Morrow <ben@morrow.me.uk> said:
> 
> >This doesn't do what you think it does...
> 
> Okay. Does this work?
> 
>     my @arglist=();

It does, but it isn't necessary. Arrays in Perl are guaranteed to start
empty, so all you need is

    my @arglist;

(If you have something like

    for (1..10) {
        my @arglist;
        ...
    }

perl will actually use the same memory for @arglist each time round the
loop, and will carefully clear it out at the end of the loop ready for
next time.)

Ben



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

Date: Wed, 18 Jan 2012 22:33:58 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: When is @_ undefined?
Message-Id: <mvtju8-tlh2.ln1@anubis.morrow.me.uk>


Quoth tmcd@panix.com:
> In article <mmdju8-fme2.ln1@anubis.morrow.me.uk>,
> Ben Morrow  <ben@morrow.me.uk> wrote:
> >No, a comma is always the comma operator. In list context it builds a
> >list, in scalar context it returns its RH argument.
> 
> As a tangent, is it more correct to say "a LIST in a scalar context
> evaluates to its length" or "an ARRAY in a scalar context evaluates to
> its length"?  I think there's a subtle distinction in Perl between
> "array" and "list" but I'm don't know the details.

A list in scalar context evaluates to its last element. An array in
scalar context evaluates to its length. It's the difference between

    sub list {
        return 4, 5, 6;
    }

    sub array {
        my @x = 4, 5, 6;
        return @x;
    }

    say scalar list;
    say scalar array;

and its an easy trap to fall into when refactoring a sub that returns a
list.

More generally: a list is a value, like '1'. An array is a variable,
like '$x'. So just as you can stuff a number into a scalar variable and
then pull it out later, you can stuff a list into an array variable and
pull it out later.

> >It's not fundamentally different from any other operator with list
> >and scalar versions, as you can see from
> >    sub foo { return 1, 2, 3; }
> >    say foo;
> >    say scalar foo;
> 
> Not the best example, because I couldn't tell whether "scalar foo" was
> evaluating to the last element or the length of the list.

Heh. Sorry :).

>     #! /usr/bin/perl
>     sub foo { return 19, 18, 17; }
>     print foo, "\n";
>     print scalar foo, "\n";
>     exit 0;
> 
> prints 17.
> 
> Though even then, someone might think foo returns a list regardless,
> and the caller might be the one who "makes it a comma operator".

Well, the internal name for 'the comma operator' (in either context) is
OP_LIST, so someone obviously thinks they're the same thing...

> A clearer example might be
> 
>     #! /usr/bin/perl
>     sub foo { return localtime; }
>     print foo, "\n";
>     print scalar foo, "\n";
>     exit 0;
> 
> printing something like
> 
>     5727141801123170
>     Wed Jan 18 14:27:57 2012
> 
> Or "return 17..19", or something else that does something different
> based on its context.

Well, the point I was making is that the comma operator isn't
fundamentally different from any of these other operators: in list
context it returns a list, in scalar context it returns something else.

Ben



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

Date: Wed, 18 Jan 2012 22:24:38 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: When is @_ undefined?
Message-Id: <4f178cf7$3$fuzhry+tra$mr2ice@news.patriot.net>

In <s6uju8-tlh2.ln1@anubis.morrow.me.uk>, on 01/18/2012
   at 10:37 PM, Ben Morrow <ben@morrow.me.uk> said:

>It does, but it isn't necessary. Arrays in Perl are guaranteed to
>start empty,

So they're guarantied to be defined?

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Thu, 19 Jan 2012 09:52:16 +0100
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
Subject: Re: When is @_ undefined?
Message-Id: <4f17d9c0$0$6584$9b4e6d93@newsspool3.arcor-online.net>

Am 19.01.2012 04:24, schrieb Shmuel (Seymour J.) Metz:
> In <s6uju8-tlh2.ln1@anubis.morrow.me.uk>, on 01/18/2012
>    at 10:37 PM, Ben Morrow <ben@morrow.me.uk> said:
> 
>> It does, but it isn't necessary. Arrays in Perl are guaranteed to
>> start empty,
> 
> So they're guarantied to be defined?

perldoc -f defined
 ...Use of "defined" on aggregates (hashes and arrays) is deprecated. It
used to report whether memory for that aggregate has ever been
allocated.  This behavior may disappear in future versions of Perl...

If we use it anyway (still works in 5.10), we can see this behaviour:

See this:
perl -E'@a=();sub t{say $_[0] if defined @a}t(1);@a=(1);t(2);@a=();t(3)'

 ...prints 2 and 3, but not 1

Both "my @arr" and "my @arr = ()" lead to the same result: an empty
array (that is not defined, i.e. memory has never been allocated for it).

But why do you care about this at all?

Wolf


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

Date: Thu, 19 Jan 2012 07:13:54 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: When is @_ undefined?
Message-Id: <4f180902$2$fuzhry+tra$mr2ice@news.patriot.net>

In <4f17d9c0$0$6584$9b4e6d93@newsspool3.arcor-online.net>, on
01/19/2012
   at 09:52 AM, Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
said:

>But why do you care about this at all?

Only to the extent that I get warnings from interpolation and join,
not otherwise.

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

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


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