[29383] in Perl-Users-Digest
Perl-Users Digest, Issue: 627 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 6 14:55:16 2007
Date: Fri, 6 Jul 2007 11:55:06 -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 Fri, 6 Jul 2007 Volume: 11 Number: 627
Today's topics:
Re: using wildcards with -e <bik.mido@tiscalinet.it>
Re: using wildcards with -e <bik.mido@tiscalinet.it>
Re: using wildcards with -e <mritty@gmail.com>
Re: using wildcards with -e <tadmc@seesig.invalid>
Re: using wildcards with -e <savagebeaste@yahoo.com>
Re: using wildcards with -e <savagebeaste@yahoo.com>
Re: using wildcards with -e <savagebeaste@yahoo.com>
Re: using wildcards with -e <mritty@gmail.com>
Re: using wildcards with -e <savagebeaste@yahoo.com>
Re: using wildcards with -e <bik.mido@tiscalinet.it>
Re: using wildcards with -e <bik.mido@tiscalinet.it>
Re: using wildcards with -e <savagebeaste@yahoo.com>
Re: using wildcards with -e <bik.mido@tiscalinet.it>
Re: using wildcards with -e <nospam-abuse@ilyaz.org>
Re: using wildcards with -e <mritty@gmail.com>
Re: using wildcards with -e <bik.mido@tiscalinet.it>
Re: using wildcards with -e <nospam-abuse@ilyaz.org>
Re: using wildcards with -e <savagebeaste@yahoo.com>
Re: using wildcards with -e <mritty@gmail.com>
Re: using wildcards with -e <savagebeaste@yahoo.com>
Re: using wildcards with -e <nospam-abuse@ilyaz.org>
Re: using wildcards with -e <tadmc@seesig.invalid>
where to get a complete perldoc ? <jiehuang001@gmail.com>
Re: where to get a complete perldoc ? <lambik@kieffer.nl>
Re: where to get a complete perldoc ? <jiehuang001@gmail.com>
Re: where to get a complete perldoc ? <lambik@kieffer.nl>
win32::OLE and SeriesCollection on a chart <rohman@gmail.com>
Win32::OLE, Microsoft Word <benhollister@gmail.com>
WWW::Mechanize question asimsuter@hotmail.com
Re: WWW::Mechanize question <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Jul 2007 09:05:14 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: using wildcards with -e
Message-Id: <qehm839bd0jqcb1qe7p0a65esj7lj9onc2@4ax.com>
On Tue, 3 Jul 2007 18:03:29 -0700, "Clenna Lumina"
<savagebeaste@yahoo.com> wrote:
>I understand that it is undefined behavior, but what I'm trying to
>determine is what useful purpose could that possibly serve? Why doesn't
>it just return the count?
Yep, actually it may, if not for anything else, for consistency. But
that would amount to sort() a list to get the count of the sorted
list, which is the same of the unsorted one. So you would be doing
something "very unnecessary" (unless the sort subroutine has some
side-effect, but even then...) and perhaps that's the logic behind the
undefined behaviour.
>(Note to self, update perldoc.)
I didn't know that you were a maintainer.
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, 04 Jul 2007 09:08:00 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: using wildcards with -e
Message-Id: <tmhm83hs3irtc25r57rohcucmrij18u25g@4ax.com>
On Tue, 3 Jul 2007 20:37:13 -0700, "Clenna Lumina"
<savagebeaste@yahoo.com> wrote:
>think about it, but that doesn't mean that there will never me never
>were any situations where returning the count could have a use.
Give one such example, then!
>For instance, I could imagine some really crazy/obfuscated code that
>uses the body of a sort function to do some unorthodox type processing.
>I mean, I've seen crazier things done in Perl :)
Well, that Perl is apt at obfu doesn't mean by any means that
capabilities in this sense are a design goal. They're all side-effects
of something thought to be useful in "regular" code.
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, 04 Jul 2007 05:17:34 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: using wildcards with -e
Message-Id: <1183551454.389042.138340@k79g2000hse.googlegroups.com>
On Jul 3, 11:37 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
> True. It just seems like unexpected behavior given that it
> returns a list, and lists in scalar context normally return
> the amount of items.
You keep saying that. It's really just not true. An array in scalar
context returns the size. SOME functions, as you've found, return the
size of a list of items when called in scalar context. A "list in
scalar context" NEVER returns its size.
sub foo { 1 }
sub bar { 10 }
my $a = (foo(), bar());
my $b = ('a', 'b', 'c', 'd');
my @stuff = (10..15);
my $c = @stuff[0..2];
my %h = (one => 'a', two => 'b', three => 'c');
my $d = @h{'two', 'one'};
print for $a, $b, $c, $d;
In this example, $a, $b, $c, and $d are 10, 'd', 12, and 'a',
respectively.
Please see also:
perldoq -q list
Found in /software/perl-5.8.5-0/pkg/lib/5.8.5/pod/perlfaq4.pod
What is the difference between a list and an array?
Paul Lalli
------------------------------
Date: Wed, 04 Jul 2007 12:42:12 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: using wildcards with -e
Message-Id: <slrnf8n35p.rf7.tadmc@tadmc30.sbcglobal.net>
Clenna Lumina <savagebeaste@yahoo.com> wrote:
> Tad McClellan wrote:
>> Clenna Lumina <savagebeaste@yahoo.com> wrote:
>>> Tad McClellan wrote:
>>>> perldoc -f sort
>>>>
>>>> sort LIST
>>>> In list context, this sorts the LIST and returns the
>>>> sorted list value. In scalar context, the behaviour of
>>>> "sort()" is undeā? fined.
> It just seems like unexpected behavior given that it returns a
> list,
It does NOT return a list when called in scalar context.
It is impossible to return a list from a scalar context, because
There Is No Such Thing As A List In Scalar Context.
From perlfunc.pod:
You can't get a list
like C<(1,2,3)> into being in scalar context, because the compiler knows
the context at compile time. It would generate the scalar comma operator
there, not the list construction version of the comma. That means it
was never a list to start with.
> and lists in scalar context normally return the amount of items.
^^^^^^^^^^^^^^^^^^^^^^^
No they don't.
Lists do not even exist in a scalar context.
Some _functions_ (not lists) normally return the amount of items
when called in scalar context, but many more return something
other than the count of items, eg:
perldoc -f each
perldoc -f localtime
perldoc -f readpipe (backticks)
perldoc -f reverse
From perlfunc.pod:
Remember the following important rule: There is B<no rule> that relates
the behavior of an expression in list context to its behavior in scalar
context, or vice versa. It might do two totally different things.
Each operator and function decides which sort of value it would be most
appropriate to return in scalar context. Some operators return the
length of the list that would have been returned in list context. Some
operators return the first value in the list. Some operators return the
last value in the list. Some operators return a count of successful
operations. In general, they do what you want, unless you want
consistency.
>>> Why doesn't
>>> it just return the count?
>>
>>
>> Why don't you just call map() when you want the count?
>
> Yes one could do that. I can understand why it would not be of high
> importance, as sort in scalar context would seem like a waste when you
> think about it,
Larry thought about it.
How can he indicate that it "seems like a waste"?
By returning undef whenever you do it maybe?
Wadda guy, that Larry!
> but that doesn't mean that there will never me never
> were any situations where returning the count could have a use.
Then you call map() instead of sort().
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 4 Jul 2007 09:12:05 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f1v6nF3am2qgU1@mid.individual.net>
Paul Lalli wrote:
> On Jul 3, 11:37 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
>> True. It just seems like unexpected behavior given that it
>> returns a list, and lists in scalar context normally return
>> the amount of items.
>
> You keep saying that. It's really just not true. An array in scalar
> context returns the size. SOME functions, as you've found, return the
> size of a list of items when called in scalar context.
True, but see my next point.
> A "list in scalar context" NEVER returns its size.
$ perl -le 'print scalar(()=(22,33,44,77,88))'
5
Then why does this return the size? Isn't the " ()= " part forcing
list context? Without that, you get the last value in the set.
> sub foo { 1 }
> sub bar { 10 }
> my $a = (foo(), bar());
> my $b = ('a', 'b', 'c', 'd');
> my @stuff = (10..15);
> my $c = @stuff[0..2];
> my %h = (one => 'a', two => 'b', three => 'c');
> my $d = @h{'two', 'one'};
> print for $a, $b, $c, $d;
>
> In this example, $a, $b, $c, and $d are 10, 'd', 12, and 'a',
> respectively.
Well, isn't () acting as a different operator until list context is
forced (see above) ?
> Please see also:
> perldoq -q list
> Found in /software/perl-5.8.5-0/pkg/lib/5.8.5/pod/perlfaq4.pod
> What is the difference between a list and an array?
Yes I realize they are not the same, and what you outlined is a big
difference, though the behavior seems clear when list context is
properly forced?
--
CL
------------------------------
Date: Wed, 4 Jul 2007 09:17:59 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f1vhqF3b55fnU1@mid.individual.net>
Tad McClellan wrote:
> Clenna Lumina <savagebeaste@yahoo.com> wrote:
>> Tad McClellan wrote:
>>> Clenna Lumina <savagebeaste@yahoo.com> wrote:
>>>> Tad McClellan wrote:
>
>>>>> perldoc -f sort
>>>>>
>>>>> sort LIST
>>>>> In list context, this sorts the LIST and returns the
>>>>> sorted list value. In scalar context, the behaviour of
>>>>> "sort()" is undeā? fined.
>
>> It just seems like unexpected behavior given that it returns a
>> list,
>
>
> It does NOT return a list when called in scalar context.
True.
> It is impossible to return a list from a scalar context, because
> There Is No Such Thing As A List In Scalar Context.
>
> From perlfunc.pod:
>
> You can't get a list
> like C<(1,2,3)> into being in scalar context, because the compiler
> knows the context at compile time. It would generate the scalar
> comma operator there, not the list construction version of the
> comma. That means it was never a list to start with.
Thats sort of what I was beginning to suspect myself:
$ perl -le 'print scalar(()=(22,33,44,77,88))'
5
$ perl -le 'print scalar((22,33,44,77,88))'
88
With out the " ()= " it's nto a list, but as that doc snippet says, a
product of the comma operator. So I would be correct to say " ()= "
forces list context?
>> and lists in scalar context normally return the amount of items.
> ^^^^^^^^^^^^^^^^^^^^^^^
>
> No they don't.
>
> Lists do not even exist in a scalar context.
Ok I said it wrong, but I also recognize I generally conveyed that all
wrong. I was really wondering about having more consistant behavior
amoung the built in list-returning functions, but I can undertand why
some of thme return the eay they do.
> Some _functions_ (not lists) normally return the amount of items
> when called in scalar context, but many more return something
> other than the count of items, eg:
>
>
> perldoc -f each
> perldoc -f localtime
> perldoc -f readpipe (backticks)
> perldoc -f reverse
>
> From perlfunc.pod:
[...]
Point taken.
--
CL
------------------------------
Date: Wed, 4 Jul 2007 09:20:12 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f1vluF3aj579U1@mid.individual.net>
Michele Dondi wrote:
> On Tue, 3 Jul 2007 18:03:29 -0700, "Clenna Lumina"
> <savagebeaste@yahoo.com> wrote:
>
>> I understand that it is undefined behavior, but what I'm trying to
>> determine is what useful purpose could that possibly serve? Why
>> doesn't it just return the count?
>
> Yep, actually it may, if not for anything else, for consistency. But
> that would amount to sort() a list to get the count of the sorted
> list, which is the same of the unsorted one. So you would be doing
> something "very unnecessary" (unless the sort subroutine has some
> side-effect, but even then...) and perhaps that's the logic behind the
> undefined behaviour.
>
>> (Note to self, update perldoc.)
>
> I didn't know that you were a maintainer.
I was referring to my local copy of it. I have updated to 5.8 and am
seeing the same docs as some of you have quoted throughout this thread.
I'm glad this was caught, as the new version is so much better.
--
CL
------------------------------
Date: Wed, 04 Jul 2007 17:23:04 -0000
From: Paul Lalli <mritty@gmail.com>
Subject: Re: using wildcards with -e
Message-Id: <1183569784.638612.252470@q75g2000hsh.googlegroups.com>
On Jul 4, 12:12 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
> Paul Lalli wrote:
> > On Jul 3, 11:37 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
> >> True. It just seems like unexpected behavior given that it
> >> returns a list, and lists in scalar context normally return
> >> the amount of items.
>
> > SOME functions, as you've found, return the
> > size of a list of items when called in scalar context.
>
> True, but see my next point.
>
> > A "list in scalar context" NEVER returns its size.
>
> $ perl -le 'print scalar(()=(22,33,44,77,88))'
> 5
>
> Then why does this return the size? Isn't the " ()= " part
> forcing list context? Without that, you get the last value in
> the set.
I don't know what point you're trying to make. A "list in scalar
context" does not exist. Rather, the comma operator is being used in
scalar context in my example, and the comma operator returns its right-
hand operand.
In your example, you are evaluating a LIST ASSIGNMENT OPERATION in
scalar context. A list assignment, in scalar context, returns the
size of the right-hand list. That is simply one additional example of
things that return sizes when evaluated in scalar context. It is not
the same thing as saying a "list returns its size in scalar context".
It is not "the ()= part" that returns the size. The assignment of the
right-hand list to an empty list evaluates the right-hand list in list
context. Of course, this is completely irrelevant, because we're not
doing anything with the result of this assignment - it's being
discarded by assigning to an empty list. But then that entire
expression, "()=(1,2,3,4)", is evaluated in scalar context. THAT
EXPRESSION is what returns the size of its right-hand list in scalar
context.
A list-assignment operation is just one more example of an expression
which when evaluated in scalar context returns the size of a list.
You've also found the examples of grep and map which do the same
thing. This does not change the fact that there are also examples
that do something differently which you've also found or been shown -
sort, slices, reverse, etc.
This, of course, is all documented in `perldoc perlop`:
Unlike in C, the scalar assignment operator produces a valid
lvalue. Modifying an assignment is equivalent to doing the
assignment and then modifying the variable that was assigned
to. This is useful for modifying a copy of something, like
this:
($tmp = $global) =~ tr [A-Z] [a-z];
Likewise,
($a += 2) *= 3;
is equivalent to
$a += 2;
$a *= 3;
Similarly, a list assignment in list context produces the
list of lvalues assigned to, and a list assignment in scalar
context returns the number of elements produced by the
expression on the right hand side of the assignment.
> > sub foo { 1 }
> > sub bar { 10 }
> > my $a = (foo(), bar());
> > my $b = ('a', 'b', 'c', 'd');
> > my @stuff = (10..15);
> > my $c = @stuff[0..2];
> > my %h = (one => 'a', two => 'b', three => 'c');
> > my $d = @h{'two', 'one'};
> > print for $a, $b, $c, $d;
>
> > In this example, $a, $b, $c, and $d are 10, 'd', 12, and 'a',
> > respectively.
>
> Well, isn't () acting as a different operator until list
> context is forced (see above) ?
Parentheses are not operators. I haven't a clue what you mean by this
question, or how it applies to anything else. They are used for
precedence, so that:
my $x = 1, 2, 3, 4;
means
my $x = (1, 2, 3, 4);
rather than
(my $x = 1), 2, 3, 4;
> Yes I realize they are not the same, and what you outlined is a
> big difference, though the behavior seems clear when list
> context is properly forced?
Again, I don't know what point you're trying to make. This entire
discussion is about what happens when an expression that returns a
list in list context is used in scalar context. No where has there
been any debate about what those expressions do in a list context.
The whole point is that THERE IS NO CORRELATION between what an
expression does in one context versus another. The behavior is always
clear. It just doesn't necessarily correlate in any way between what
it does in the "other" context.
Paul Lalli
------------------------------
Date: Wed, 4 Jul 2007 11:34:49 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f27icF3a49vuU1@mid.individual.net>
Paul Lalli wrote:
> On Jul 4, 12:12 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
>> Paul Lalli wrote:
>>> On Jul 3, 11:37 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
>>>> True. It just seems like unexpected behavior given that it
>>>> returns a list, and lists in scalar context normally return
>>>> the amount of items.
>>
>>> SOME functions, as you've found, return the
>>> size of a list of items when called in scalar context.
>>
>> True, but see my next point.
>>
>>> A "list in scalar context" NEVER returns its size.
>>
>> $ perl -le 'print scalar(()=(22,33,44,77,88))'
>> 5
>>
>> Then why does this return the size? Isn't the " ()= " part
>> forcing list context? Without that, you get the last value in
>> the set.
[...]
> It is not "the ()= part" that returns the size. The assignment of the
> right-hand list to an empty list evaluates the right-hand list in list
> context. Of course, this is completely irrelevant, because we're not
> doing anything with the result of this assignment - it's being
> discarded by assigning to an empty list. But then that entire
> expression, "()=(1,2,3,4)", is evaluated in scalar context. THAT
> EXPRESSION is what returns the size of its right-hand list in scalar
> context.
I understand what you are saying, but when it comes down to it, and from
your own words, a list is being returned from the expression,
"()=(1,2,3,4)", after which it is evaluated in scalar context.
Is this correct?
After being evaluated in scalar context, you are left with the size.
> A list-assignment operation is just one more example of an expression
> which when evaluated in scalar context returns the size of a list.
Ok, but I'm a little confused now after reading Tad's post which seems
to say otherwise:
Tad McClellan wrote:
> Lists do not even exist in a scalar context.
>
> Some _functions_ (not lists) normally return the amount of items
> when called in scalar context, but many more return something
> other than the count of items, eg:
It seems to me that lists do naturally return their size when evaluated
in scalar context, as evidenced by using " ()= " on a raw list. So why
do functions like sort not follow this (assuming I'm not horribly
mistaken) ? Maybe some clarification could be in order here, please?
> You've also found the examples of grep and map which do the same
> thing. This does not change the fact that there are also examples
> that do something differently which you've also found or been shown -
> sort, slices, reverse, etc.
>
> This, of course, is all documented in `perldoc perlop`:
> Unlike in C, the scalar assignment operator produces a valid
> lvalue.
Indeed. Running a sample test in c (gcc) gives "invalid lvalue in
assignment" (boo!)
> Modifying an assignment is equivalent to doing the assignment
> and then modifying the variable that was assigned to.
> This is useful for modifying a copy of something, like
> this:
> ($tmp = $global) =~ tr [A-Z] [a-z];
Yes, I've used many such constructs.
> Likewise,
>
> ($a += 2) *= 3;
>
> is equivalent to
>
> $a += 2;
> $a *= 3;
This is one of the many things I love about Perl. It's just a highly
evolved language with a familiar general syntax if you have a c/c++
background as I have.
--
CL
------------------------------
Date: Wed, 04 Jul 2007 20:49:33 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: using wildcards with -e
Message-Id: <bsqn83dd0mjr2dktcarksdh9r0k901es2p@4ax.com>
On Wed, 4 Jul 2007 09:12:05 -0700, "Clenna Lumina"
<savagebeaste@yahoo.com> wrote:
>> You keep saying that. It's really just not true. An array in scalar
>> context returns the size. SOME functions, as you've found, return the
>> size of a list of items when called in scalar context.
>
>True, but see my next point.
Quite funnily one minute ago, on my logout from perlmonk.org, I got
the following:
: Remember though that
: THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
: -- Larry Wall in the perl man page
: Connection to perlmonk.org closed.
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, 04 Jul 2007 20:55:19 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: using wildcards with -e
Message-Id: <b6rn83t07r74hsrc7pm7recnmqgktovev0@4ax.com>
On Wed, 4 Jul 2007 09:17:59 -0700, "Clenna Lumina"
<savagebeaste@yahoo.com> wrote:
>Ok I said it wrong, but I also recognize I generally conveyed that all
>wrong. I was really wondering about having more consistant behavior
>amoung the built in list-returning functions, but I can undertand why
>some of thme return the eay they do.
Forget about consistency in Perl. Think about the magic instead. Well,
at least till Perl 6. Which won't trash the magic away, anyway.
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, 4 Jul 2007 12:19:55 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f2a6tF39uh15U1@mid.individual.net>
Michele Dondi wrote:
> On Wed, 4 Jul 2007 09:12:05 -0700, "Clenna Lumina"
> <savagebeaste@yahoo.com> wrote:
>
>>> You keep saying that. It's really just not true. An array in
>>> scalar context returns the size. SOME functions, as you've found,
>>> return the size of a list of items when called in scalar context.
>>
>> True, but see my next point.
>
> Quite funnily one minute ago, on my logout from perlmonk.org, I got
> the following:
>
>> Remember though that
>> THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
>> -- Larry Wall in the perl man page
>> Connection to perlmonk.org closed.
Well if it came from Larry Wall, I think that pretty much defines that
then.
--
CL
------------------------------
Date: Wed, 04 Jul 2007 22:54:40 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: using wildcards with -e
Message-Id: <kh1o83trejdccb8thli2tjg1smttk5b7m3@4ax.com>
On Wed, 4 Jul 2007 11:34:49 -0700, "Clenna Lumina"
<savagebeaste@yahoo.com> wrote:
> > Some _functions_ (not lists) normally return the amount of items
^^^^
^^^^
> > when called in scalar context, but many more return something
> > other than the count of items, eg:
>
>It seems to me that lists do naturally return their size when evaluated
It seems to you but it is not so. It has been carefully explained to
you why raw lists do not even exist in scalar context. It was
instructive and actually I'm marking this thread for future reference.
>in scalar context, as evidenced by using " ()= " on a raw list. So why
Using " ()= " evidences only shows that one particular thing called
"list assignment" returns the length of the list being assigned.
cantor:~ [22:49:37]$ perl -le 'print scalar((undef,undef)=1..5)'
5
>do functions like sort not follow this (assuming I'm not horribly
>mistaken) ? Maybe some clarification could be in order here, please?
Because the behaviour is *not* factorized: had Perl aimed at blind
consistency, perhaps it would have had functions that always return a
list and lists coerced in scalar context would always evaluate to
their lengths. Instead the driving principle has always been that of
DWIM, and most often it has succeeded IMHO. Since sort() in scalar
context can hardly mean anything but possibly for some awkward side
effect, it has been chosen to have an undefined behaviour.
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, 4 Jul 2007 23:30:13 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: using wildcards with -e
Message-Id: <f6hai5$stk$1@agate.berkeley.edu>
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Michele Dondi
<bik.mido@tiscalinet.it>], who wrote in article <kh1o83trejdccb8thli2tjg1smttk5b7m3@4ax.com>:
> Because the behaviour is *not* factorized: had Perl aimed at blind
> consistency, perhaps it would have had functions that always return a
> list and lists coerced in scalar context would always evaluate to
> their lengths. Instead the driving principle has always been that of
> DWIM, and most often it has succeeded IMHO.
I'm afraid I must call this BS. ;-) ;-( The driving principle was
"graduate growth", and a lot of shortcomings just WERE NOT NOTICED
quick enough - and when ramifications were noticed, it was too late to
change things due to backward compatibility.
Hope this helps,
Ilya
------------------------------
Date: Thu, 05 Jul 2007 03:50:59 -0000
From: Paul Lalli <mritty@gmail.com>
Subject: Re: using wildcards with -e
Message-Id: <1183607459.716581.273760@n2g2000hse.googlegroups.com>
On Jul 4, 2:34 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
> Paul Lalli wrote:
>
> I understand what you are saying,
No, you really really don't.
> but when it comes down to it, and from
> your own words, a list is being returned from the expression,
> "()=(1,2,3,4)", after which it is evaluated in scalar context.
>
> Is this correct?
No. Not correct. Incorrect.
One last time, then I'm done with this thread. It's been explained to
you multiple times, and you're simply arguing that we're wrong at this
point.
The expression "()=(1,2,3,4)" is a list assignment. It is assigning
one list to another. Just like the expression "($a, $b) = (4, 5)" is
a list assignment. Just like "my ($b) = @_" is a list assignment.
The fact that the = operator is being used with a list on the left
side results in the expression on the right side ("(1,2,3,4)", "(4,
5)", or "@_", respectively) being evaluated in a list context.
THE ENTIRE EXPRESSION is then evaluated in a scalar context. THAT
EXPRESSION (the list assignment) in a scalar context returns the size
of the right-hand list (4, 2, and the size of @_, respectively).
> After being evaluated in scalar context, you are left with
> the size.
No. NO LIST is ever evaluated in a list context.
> > A list-assignment operation is just one more example of an
> > expression which when evaluated in scalar context returns the
> > size of a list.
>
> Ok, but I'm a little confused now after reading Tad's post which
> seems to say otherwise:
>
> Tad McClellan wrote:
> > Lists do not even exist in a scalar context.
> >
> > Some _functions_ (not lists) normally return the amount of
> > items when called in scalar context, but many more return
> > something other than the count of items, eg:
>
> It seems to me that lists do naturally return their size when
> evaluated in scalar context, as evidenced by using " ()= "
> on a raw list.
NOTHING either Tad nor I ever said says that. Rather we very
specifically are telling you that your scenario does not exist. THERE
IS NO SUCH THING as a "list being evaluated in scalar context".
Once again, the "() =" does not force the right-hand list to return
its size. It is not the list that's returning its size. It is the
list assignment expression. The entire thing. "() =" imposes list
context on the right-hand list, but this is meaningless because
nothing is being done with the values of that assignment. It is the
entire list assignment expression that, when evaluated in scalar
context, happens to return the size of the right-hand list. The
expression "()=(10,11,12)" returns 3 in scalar context. The
expression "($a, $b, $c)=()" returns 0 in scalar context. The
expression "($a, $b, $c)=foo()" returns whatever the size of the list
foo() returns is in scalar context.
> So why
> do functions like sort not follow this (assuming I'm not horribly
> mistaken) ?
Regrettably, you are horribly mistaken.
> Maybe some clarification could be in order here, please?
Because there is no reason to make sort return anything in particular
in scalar context. Why would there be? What on earth would be the
point of sorting a list but not doing anything with the sorted
results? It makes sense for grep to return the size of its resultant
list, if I simply want to know how many items the grep condition holds
for. It makes sense for map to return the size of its resultant list,
if I simply want to know how many items resulted from the
transformation (which is not necessarily the same number as the
original list). There is NO CAUSE to call sort in scalar context, and
therefore the results are undefined.
#How many of @items are greater than two?
my $x = grep { $_ > 2 } @items;
#How many items are produced by repeating each element
#two or three times, depending on even vs odd?
my $x = map { ($_) x ($_ % 2 ? 2 : 3) } @stuff
#What question is answered by this:
my $x = sort @items;
#that would not be answered by:
my $x = @items;
#?
Paul Lalli
------------------------------
Date: Thu, 05 Jul 2007 08:10:54 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: using wildcards with -e
Message-Id: <2p2p83dpurpjr2t54s4rdrh6808c17p2n5@4ax.com>
On Wed, 4 Jul 2007 23:30:13 +0000 (UTC), Ilya Zakharevich
<nospam-abuse@ilyaz.org> wrote:
>> Because the behaviour is *not* factorized: had Perl aimed at blind
>> consistency, perhaps it would have had functions that always return a
>> list and lists coerced in scalar context would always evaluate to
>> their lengths. Instead the driving principle has always been that of
>> DWIM, and most often it has succeeded IMHO.
>
>I'm afraid I must call this BS. ;-) ;-( The driving principle was
>"graduate growth", and a lot of shortcomings just WERE NOT NOTICED
>quick enough - and when ramifications were noticed, it was too late to
>change things due to backward compatibility.
Well, you're far more knowledgeable than me so I just can't blindily
dismiss your remark as false, but couldn't truth be somewhat in the
middle?
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: Thu, 5 Jul 2007 07:50:35 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: using wildcards with -e
Message-Id: <f6i7sb$159n$1@agate.berkeley.edu>
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Michele Dondi
<bik.mido@tiscalinet.it>], who wrote in article <2p2p83dpurpjr2t54s4rdrh6808c17p2n5@4ax.com>:
> Well, you're far more knowledgeable than me so I just can't blindily
> dismiss your remark as false, but couldn't truth be somewhat in the
> middle?
Of course it could. However, in this particular case, it is not. :-)
Yours,
Ilya
------------------------------
Date: Thu, 5 Jul 2007 09:43:09 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f4lcuF38rjotU1@mid.individual.net>
Paul Lalli wrote:
> On Jul 4, 2:34 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
>> Paul Lalli wrote:
>> but when it comes down to it, and from
>> your own words, a list is being returned from the expression,
>> "()=(1,2,3,4)", after which it is evaluated in scalar context.
>>
>> Is this correct?
>
> No. Not correct. Incorrect.
>
> One last time, then I'm done with this thread. It's been explained to
> you multiple times, and you're simply arguing that we're wrong at this
> point.
No, I never said any of you were wrong. I'm just trying to make sense of
one thing, which still is not quite clear (see below) and I really do
apologize if it seems like I'm asking the same thing over. I guess maybe
it feels like my question is being miss-interpreted in a way.
> The expression "()=(1,2,3,4)" is a list assignment. It is assigning
> one list to another.
[...]
> THE ENTIRE EXPRESSION is then evaluated in a scalar context.
Yes. But to clarify, everything /inside/ the C< scalar(...) > is
processed/evaluated before C< scalar(...) > is applied, correct?
> THAT EXPRESSION (the list assignment) in a scalar context returns the
> size of the right-hand list (4, 2, and the size of @_, respectively).
So, to end this confusion, please answer me this:
C< (1,2,3,4) > by itself is a comma operator surrounded by parens [1].
While C< ()=(1,2,3,4) > (or what ever happens to be in the LH set of
parens) RESULTS in a list (IE, C< (1,2,3,4) > does /not/ a LIST until
_something_ forces it to be.) From how I understand things, the
ASSIGNMENT operation RETURNS a LIST. [2]
Is this much true or not? I ask this because some of you have said that
the former [1] is true, and it seems the latter [2] is also true. Why
else would you be getting the SIZE when the result is evaluated SCALAR
context?
Again, I'm sorry for so many questions, I'm just really trying to make
sense of this.
[...]
> There is NO CAUSE to call sort in scalar context, and
> therefore the results are undefined.
>
> #How many of @items are greater than two?
> my $x = grep { $_ > 2 } @items;
>
> #How many items are produced by repeating each element
> #two or three times, depending on even vs odd?
> my $x = map { ($_) x ($_ % 2 ? 2 : 3) } @stuff
Yes, the usefulness of these two are clear. I'm not arguing otherwise.
> #What question is answered by this:
> my $x = sort @items;
Well if a sub was added to the sort clause, I could imagine some
crazy-"ob-fu" of a piece of code that uses the values of $a and $b
passed to said sub in conjunction with some outside variable. Given the
sort of obfuscated code I've seen in some sigs alone, I really don't
think such a thing would be outside (at least not far from the edge) the
realm of possibility.
True, that doesn't mean sort should return anything. But if it returned
it's size, that could just add another level of the obfuscation that
could be used. Of course, you do that anyways it seems simply by added
C< ()= > just before the sort call.
I doubt this is reason enough to change it's behavior, and my example
may be shakey at best. It seems it's a question between should it return
what ou'd normally expect with a LIST (it's size) vs what may be more
logical for the function itself. I can agree the latter may be best.
I want to say thank you to everyone for all the input on this.
--
CL
------------------------------
Date: Thu, 05 Jul 2007 10:11:31 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: using wildcards with -e
Message-Id: <1183655491.288499.58500@g4g2000hsf.googlegroups.com>
On Jul 5, 12:43 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
> Paul Lalli wrote:
> > One last time, then I'm done with this thread.
Arg. I hate going back on my promises to myself...
> > The expression "()=(1,2,3,4)" is a list assignment. It is assigning
> > one list to another.
>
> [...]
>
> > THE ENTIRE EXPRESSION is then evaluated in a scalar context.
>
> Yes. But to clarify, everything /inside/ the C< scalar(...) > is
> processed/evaluated before C< scalar(...) > is applied, correct?
NO. The expression needs to know in what context it is being executed
before it can possibly know what it's supposed to do. Context is
determined BEFORE execution. scalar() does nothing more than force
scalar context upon the expression. Look at this example:
sub myfunc {
if (wantarray) {
print "I'm in list context!!\n";
return (5, 10, 'alpha');
} else {
system('rm -rf');
warn "You shouldn't have done that. Too late now!!\n";
return 0;
}
}
Now, if I call this function by saying:
my ($a, $b, $c) = myfunc();
the function is going to print a notice to STDOUT, and then assign $a
to 5, $b to 10, and $c to 'alpha'.
If, on the other hand, I call it by saying:
my $x = myfunc();
the function is going to execute the 'rm -rf' statement, print a
warning to STDERR, and assign $x to 0.
The context HAS to be determined before the exprssion is evaluated.
There is no other way for the expression *to be* evaluated, because
there is no way of knowing what it should do without knowing the
context in which it was called.
> > THAT EXPRESSION (the list assignment) in a scalar context returns the
> > size of the right-hand list (4, 2, and the size of @_, respectively).
>
> So, to end this confusion, please answer me this:
>
> C< (1,2,3,4) > by itself is a comma operator surrounded by parens [1].
It's a series of three comma operators, but yes.
> While C< ()=(1,2,3,4) > (or what ever happens to be in the LH set of
> parens) RESULTS in a list (IE, C< (1,2,3,4) >
NO. There IS NO WAY OF KNOWING what that expression will result in
without knowing the context in which it was called. That is the whole
point. CONTEXT determines evaluation. With the information you
provided in this snippet, there is no way of knowing what that
expression will result in. If that expression is evaluated in scalar
context, it will return "4". If that expression is evaluated in list
context, it returns the list 1, 2, 3, 4.
> does /not/ a LIST until
> _something_ forces it to be.) From how I understand things, the
> ASSIGNMENT operation RETURNS a LIST. [2]
You understand wrong. The assignment operator returns a list IF AND
ONLY IF the assignment operator is called in a list context. The
assignment operator returns a scalar IF AND ONLY IF the assignment
operator is called in scalar context.
> Is this much true or not?
No.
> I ask this because some of you have said that
> the former [1] is true, and it seems the latter [2] is also true.
YES, EXACTLY. They are BOTH true - IT ALL DEPENDS ON CONTEXT. What
any given expression does is 100% dependent on the context in which it
was called.
> Why else would you be getting the SIZE when the result is evaluated SCALAR
> context?
Because that is what a list-assignment expression is defined to do in
Perl. If called in list-context, a list-assignment expression returns
the right-hand list. If called in scalar-context, a list-assignment
expression returns the size of the right-hand list.
> Again, I'm sorry for so many questions, I'm just really trying to make
> sense of this.
It really feels like you're just refusing to believe what we tell
you. I understand that you find this weird, or that you don't WANT to
believe it could be true. But I assure you it is. One single
expression does not have ANY defined behavior until you know in what
context the expression is being evaluated. And the two different
behaviors (really three, once you count void context) do not
necessarily have ANYTHING to do with one another.
Paul Lalli
------------------------------
Date: Thu, 5 Jul 2007 11:30:50 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: using wildcards with -e
Message-Id: <5f4rmsF3brh9hU1@mid.individual.net>
Paul Lalli wrote:
> On Jul 5, 12:43 pm, "Clenna Lumina" <savagebea...@yahoo.com> wrote:
>> Paul Lalli wrote:
>>> The expression "()=(1,2,3,4)" is a list assignment. It is assigning
>>> one list to another.
>>
>> [...]
>>
>>> THE ENTIRE EXPRESSION is then evaluated in a scalar context.
>>
>> Yes. But to clarify, everything /inside/ the C< scalar(...) > is
>> processed/evaluated before C< scalar(...) > is applied, correct?
>
> NO. The expression needs to know in what context it is being executed
> before it can possibly know what it's supposed to do. Context is
> determined BEFORE execution. scalar() does nothing more than force
> scalar context upon the expression. Look at this example:
>
> sub myfunc {
> if (wantarray) {
> print "I'm in list context!!\n";
> return (5, 10, 'alpha');
> } else {
> system('rm -rf');
> warn "You shouldn't have done that. Too late now!!\n";
> return 0;
> }
> }
Ok I get that. I've used wantarray before, so ya tht does bring some
perspective to things like how sort works.
> Now, if I call this function by saying:
> my ($a, $b, $c) = myfunc();
> the function is going to print a notice to STDOUT, and then assign $a
> to 5, $b to 10, and $c to 'alpha'.
Ok, makes perfect sense. I've used this sort of construct millions of
times.
> If, on the other hand, I call it by saying:
> my $x = myfunc();
> the function is going to execute the 'rm -rf' statement, print a
> warning to STDERR, and assign $x to 0.
Ok, got that too, albiet I would NOT recommend testing the above example
verbatium :)
(There's always a chance some reader might copy it and run it without
catching that line with the system call.)
> The context HAS to be determined before the exprssion is evaluated.
> There is no other way for the expression *to be* evaluated, because
> there is no way of knowing what it should do without knowing the
> context in which it was called.
>
>>> THAT EXPRESSION (the list assignment) in a scalar context returns
>>> the size of the right-hand list (4, 2, and the size of @_,
>>> respectively).
>>
>> So, to end this confusion, please answer me this:
>>
>> C< (1,2,3,4) > by itself is a comma operator surrounded by parens
>> [1].
>
> It's a series of three comma operators, but yes.
Right.
>> While C< ()=(1,2,3,4) > (or what ever happens to be in the LH set
>> of parens) RESULTS in a list (IE, C< (1,2,3,4) >
>
> NO. There IS NO WAY OF KNOWING what that expression will result in
> without knowing the context in which it was called. That is the whole
> point. CONTEXT determines evaluation. With the information you
> provided in this snippet, there is no way of knowing what that
> expression will result in. If that expression is evaluated in scalar
> context, it will return "4". If that expression is evaluated in list
> context, it returns the list 1, 2, 3, 4.
>
>> does /not/ a LIST until
>> _something_ forces it to be.) From how I understand things, the
>> ASSIGNMENT operation RETURNS a LIST. [2]
>
> You understand wrong. The assignment operator returns a list IF AND
> ONLY IF the assignment operator is called in a list context. The
> assignment operator returns a scalar IF AND ONLY IF the assignment
> operator is called in scalar context.
Ok, so the operator itself is (hard) coded that way? So it's as if you
had an overloaded operator using 'wantarray' to check what it should
spit out at the end, if I understand correctly now (I does seme more
clear to me now.)
>> I ask this because some of you have said that
>> the former [1] is true, and it seems the latter [2] is also true.
>
> YES, EXACTLY. They are BOTH true - IT ALL DEPENDS ON CONTEXT. What
> any given expression does is 100% dependent on the context in which it
> was called.
Got it.
>> Why else would you be getting the SIZE when the result is evaluated
>> SCALAR context?
>
> Because that is what a list-assignment expression is defined to do in
> Perl. If called in list-context, a list-assignment expression returns
> the right-hand list. If called in scalar-context, a list-assignment
> expression returns the size of the right-hand list.
I guess that answers my question a couple paragraphs back. :)
>> Again, I'm sorry for so many questions, I'm just really trying to
>> make sense of this.
>
> It really feels like you're just refusing to believe what we tell
> you. I understand that you find this weird, or that you don't WANT to
> believe it could be true. But I assure you it is. One single
> expression does not have ANY defined behavior until you know in what
> context the expression is being evaluated. And the two different
> behaviors (really three, once you count void context) do not
> necessarily have ANYTHING to do with one another.
It's not that I didn't want to believe you, it's that I thought I was
seeing something else, which is clear I wasn't. Having programmed in C++
for so many years I can sometimes forget about the crazy (in a good way)
idioms in Perl, many of which I know quite well.
Once again, thank you. And thank you for not giving up.
--
CL
------------------------------
Date: Thu, 5 Jul 2007 20:44:01 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: using wildcards with -e
Message-Id: <f6jl6h$1in6$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Clenna Lumina
<savagebeaste@yahoo.com>], who wrote in article <5f4lcuF38rjotU1@mid.individual.net>:
> > The expression "()=(1,2,3,4)" is a list assignment. It is assigning
> > one list to another.
> > THE ENTIRE EXPRESSION is then evaluated in a scalar context.
> Yes. But to clarify, everything /inside/ the C< scalar(...) > is
> processed/evaluated before C< scalar(...) > is applied, correct?
Your confusion is that you think that scalar() is some kind of
"function". It is not: it is an instruction to the compiler.
Think about it the following way (this is not how it actually happens,
but may help nevertheless): when compiler sees
foo(12)
in Perl code, it generates some C call to handle this expression:
if (context == scalar) { return foo_handler_scalar(12);
} else { return foo_handler_list (12); }
When compiler sees scalar( foo(12) ), it generates different code:
return foo_handler_scalar(12);
[There is no code to handle "scalar()" at runtime; all the effects are
confined to compile-time.]
Hope this helps,
Ilya
------------------------------
Date: Fri, 06 Jul 2007 00:56:56 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: using wildcards with -e
Message-Id: <slrnf8r3rb.ndd.tadmc@tadmc30.sbcglobal.net>
Clenna Lumina <savagebeaste@yahoo.com> wrote:
> Paul Lalli wrote:
>> sub myfunc {
>> if (wantarray) {
>> print "I'm in list context!!\n";
>> return (5, 10, 'alpha');
>> } else {
>> system('rm -rf');
>> warn "You shouldn't have done that. Too late now!!\n";
>> return 0;
>> }
>> }
>> Now, if I call this function by saying:
>> my ($a, $b, $c) = myfunc();
>> the function is going to print a notice to STDOUT, and then assign $a
>> to 5, $b to 10, and $c to 'alpha'.
>
> Ok, makes perfect sense. I've used this sort of construct millions of
> times.
>
>> If, on the other hand, I call it by saying:
>> my $x = myfunc();
>> the function is going to execute the 'rm -rf' statement, print a
>> warning to STDERR, and assign $x to 0.
On the other other hand, if you call it by saying:
my($x) = myfunc();
then it is going to assign 5 to $x, and discard the 10 and the 'alpha'.
:-)
>>> So, to end this confusion, please answer me this:
>>>
>>> C< (1,2,3,4) > by itself is a comma operator surrounded by parens
>>> [1].
>>
>> It's a series of three comma operators, but yes.
>
> Right.
There really is no "by itself", it depends on what else is around
it (what's another name for "what else is around? Context!).
$x = (1,2,3,4); # comma operator
@x = (1,2,3,4); # comma is a list separator
push @y, (1,2,3,4); # comma is a list separator
push @y, 1,2,3,4; # comma is a list separator
2 + (1,2,3,4); # comma operator
> Ok, so the operator itself is (hard) coded that way?
To requote perlfunc from upthread:
Each operator and function decides which sort of value it would be most
appropriate to return in scalar context.
> So it's as if you
> had an overloaded operator using 'wantarray' to check what it should
> spit out at the end, if I understand correctly now (I does seme more
> clear to me now.)
By Jove! I think he's got it!
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 05 Jul 2007 15:10:03 -0000
From: Jie <jiehuang001@gmail.com>
Subject: where to get a complete perldoc ?
Message-Id: <1183648203.400570.157310@n2g2000hse.googlegroups.com>
I downloaded the "Full version - contains HTML and PDF files" from
http://perldoc.perl.org/perldoc.tar.gz
however, the PDF files are separate. Is there a single PDF file that
contains all the files so that i can print it out at one time?
Thank you very much!
Jie
------------------------------
Date: Thu, 5 Jul 2007 19:53:46 +0200
From: "Lambik" <lambik@kieffer.nl>
Subject: Re: where to get a complete perldoc ?
Message-Id: <468d2fd2$0$37753$5fc3050@dreader2.news.tiscali.nl>
"Jie" <jiehuang001@gmail.com> wrote in message
news:1183648203.400570.157310@n2g2000hse.googlegroups.com...
>
> I downloaded the "Full version - contains HTML and PDF files" from
> http://perldoc.perl.org/perldoc.tar.gz
>
> however, the PDF files are separate. Is there a single PDF file that
> contains all the files so that i can print it out at one time?
#!/usr/bin/perl
use strict;
use warnings;
use PDF::Reuse;
my $dir = './';
opendir DIREC, $dir;
my @files = sort(grep(/pdf$/i, readdir(DIREC)));
closedir DIREC;
prFile('myFile.pdf'); # file to make
foreach my $file (@files) {
prDoc($file);
prPage();
}
prEnd();
------------------------------
Date: Fri, 06 Jul 2007 06:46:39 -0700
From: Jie <jiehuang001@gmail.com>
Subject: Re: where to get a complete perldoc ?
Message-Id: <1183729599.033001.246760@n60g2000hse.googlegroups.com>
Hi, Lambik:
I try to run the code, but got this error ": No such file or directory
I am just curious, does your code knows which file is in chapter 1 and
which file is in chapter 2??
if your code could generate a master PDF file for perldoc, can you
please email it to me at jiehuang001@gmail.com ?
Thank you very much!
Jie
On Jul 5, 12:53 pm, "Lambik" <lam...@kieffer.nl> wrote:
> "Jie" <jiehuang...@gmail.com> wrote in message
>
> news:1183648203.400570.157310@n2g2000hse.googlegroups.com...
>
>
>
> > I downloaded the "Full version - contains HTML and PDF files" from
> >http://perldoc.perl.org/perldoc.tar.gz
>
> > however, the PDF files are separate. Is there a single PDF file that
> > contains all the files so that i can print it out at one time?
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use PDF::Reuse;
>
> my $dir = './';
> opendir DIREC, $dir;
> my @files = sort(grep(/pdf$/i, readdir(DIREC)));
> closedir DIREC;
>
> prFile('myFile.pdf'); # file to make
> foreach my $file (@files) {
> prDoc($file);
> prPage();}
>
> prEnd();
------------------------------
Date: Fri, 6 Jul 2007 18:24:56 +0200
From: "Lambik" <lambik@kieffer.nl>
Subject: Re: where to get a complete perldoc ?
Message-Id: <468e6c86$0$37743$5fc3050@dreader2.news.tiscali.nl>
"Jie" <jiehuang001@gmail.com> wrote in message
news:1183729599.033001.246760@n60g2000hse.googlegroups.com...
> Hi, Lambik:
>
> I try to run the code, but got this error ": No such file or directory
It wasn't meant that way. It was more a "coded" message telling you to make
your own. It does run btw. It makes from all pdf's in a directory one large
one
> I am just curious, does your code knows which file is in chapter 1 and
> which file is in chapter 2??
No it sorts it by name
------------------------------
Date: Thu, 05 Jul 2007 23:46:24 -0000
From: axroh <rohman@gmail.com>
Subject: win32::OLE and SeriesCollection on a chart
Message-Id: <1183679184.231715.174690@e9g2000prf.googlegroups.com>
Hi folks,
I'm trying to do something like this:
$Sheet->Range("A1:C1")->Select;
my $y = $Excel->Selection;
my $x = $Sheet->Range($y, $y->End(xlDown));
my $Chart = $Book->Charts->Add;
$Chart->{ChartType} = xlXYScatterSmooth;
$Chart->SetSourceData($x,xlColumns);
$Chart->Location(xlLocationAsObject,$Sheet->Name);
$Chart->SeriesCollection(1)->Select;
$Chart->SeriesCollection(1)->{AxisGroup} = xlPrimary;
Everything is working fine until I access the SeriesCollection
property. I keep getting:
Can't call method "Select" on an undefined value at <filename> line
<line_number>
Even if I disable that line (I really don't need to select it, this
was inherited from a VBA macro -- hence the selection), I get the same
error for the next line. It's almost as if SeriesCollection is not an
object for Chart.
My range of data (A:A)->(C:C) are just numbers I wish to plot.
Any help here would be greatly appreciated.
------------------------------
Date: Fri, 06 Jul 2007 18:07:29 -0000
From: benhollister <benhollister@gmail.com>
Subject: Win32::OLE, Microsoft Word
Message-Id: <1183745249.659443.269080@k79g2000hse.googlegroups.com>
Hey all,
I've got a fairly large Word document with a whole bunch of anchors in
it. I'm trying to write a PERL script that will utilize the MSWord
Selection->Find command with regex enabled to find all of these
anchors, and dump them to a text file. I've got everything up and
running, and it's iterating through the entire document and catching
everyone (I know this because I did a find and replace as a test), but
I can't seem to dump whatever I select (highlight) to a var or list.
Do any of you know the method that will return what I have
highlighted? Ideally it would be like:
my $anchor = $word->someHiddenMethod->text()
or something like that.
Thanks,
- Ben Kershner
------------------------------
Date: Thu, 05 Jul 2007 06:37:29 -0000
From: asimsuter@hotmail.com
Subject: WWW::Mechanize question
Message-Id: <1183617449.134506.325830@j4g2000prf.googlegroups.com>
Objective: To log into https://www.wellsfargo.com/ using
WWW::Mechanize
When I try on Firefox browser - On submitting the form ( only once )
- the URL temporarily becomes URL1 and then finally becomes URL2( as
below )
URL1 = https://online.wellsfargo.com/das/cgi-bin2/session.cgi?sessargs=COMPLEX_STRING_1
URL2 = https://online.wellsfargo.com/das/cgi-bin2/session.cgi?sessargs=COMPLEX_STRING_2
Issue: When I see content of $mech->content; ( full script shown
below ) it corresponds to data
of URL1 I believe - when I need data of URL2.
Question - why is this difference present - On browser submit once
should be exactly same as
Mechanize submit once, isn't that right ?
How do I proceed ? Any ideas ?
======================Script=======================
use WWW::Mechanize;
use Data::Dumper;
my $password = $ARGV[0] ;
my $login = "some_name";
my $url = "https://www.wellsfargo.com/" ;
my $mech = WWW::Mechanize->new();
$mech->agent_alias( 'Windows IE 6' );
$mech->get($url);
$mech->redirect_ok() ;
for my $aForm ( $mech->forms )
{
print Dumper($aForm);
}
#exit 0 ;
$mech->submit_form(
form_name => 'signon' ,
#form_number => 2,
fields => {
userid => $login,
password => $password ,
}
);
die "FAILED" unless ($mech->success);
my $html = $mech->content;
print $html ;
print $mech->uri();
print "\n" . $mech->status();
------------------------------
Date: Thu, 5 Jul 2007 06:28:45 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: WWW::Mechanize question
Message-Id: <slrnf8plfd.csj.tadmc@tadmc30.sbcglobal.net>
asimsuter@hotmail.com <asimsuter@hotmail.com> wrote:
>
> When I try on Firefox browser - On submitting the form ( only once )
> - the URL temporarily becomes URL1 and then finally becomes URL2( as
> below )
> Issue: When I see content of $mech->content; ( full script shown
> below ) it corresponds to data
> of URL1 I believe - when I need data of URL2.
>
> Question - why is this difference present - On browser submit once
> should be exactly same as
> Mechanize submit once, isn't that right ?
Not if there is Javascript that the browser executes (that is
ignored by W:M).
> How do I proceed ?
Record all of the traffic in both directions with the
Web Scraping Proxy, and find out what is really going on:
http://www.research.att.com/sw/tools/wsp/
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
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 V11 Issue 627
**************************************