hi,
if we ignore the possibility that the following code could
ruin your day, it could be considered dark fun:
this one:
use strict;
for(1..3)
{
my $id = 1 if $_ == 3;
print [$id]\n;
$id = 999;
}
prints:
[]
[999]
[1]
why?!
`my $id' defines new var every time in the loop, so
On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote:
my $id = 1 if $_ == 3;
my has a compile time behavior and a runtime behavior. At compile time, my
allocates memory for the variable and adds it to the pad. At run time, my
resets the value of the variable.
If you
On 1 Jul 2003 at 17:15, Vladi Belperchinov-Shabanski wrote:
this one:
use strict;
for(1..3)
{
my $id = 1 if $_ == 3;
print [$id]\n;
$id = 999;
}
This is just another instance of what I've posted about [on c.l.p.m] a
few times, cheap static variables. Perl's mechanism for
On 1 Jul 2003 at 10:30, Ronald J Kimball wrote:
On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote:
my $id = 1 if $_ == 3;
[...]
This was an accidental feature that is now kept for backwards
compatibility, because some programmers have used it to create
On Tue, 1 Jul 2003 10:30:34 -0400
Ronald J Kimball [EMAIL PROTECTED] wrote:
On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote:
my $id = 1 if $_ == 3;
my has a compile time behavior and a runtime behavior. At compile time, my
allocates memory for the variable
yes I see this funny usage :) but I rather
have both behaviours (compile+runtime) merged
somehow...
looks like this only makes sense if
my $var = expr;
is allowed, and
my $var = expr if/unless cond;
forbidden... or replaced with `?:'
my $var = cond ? expr : undef
or even
my $var = cond ?
On 1 Jul 2003 at 17:01, Ton Hospel wrote:
In article [EMAIL PROTECTED],
Bernie Cosell [EMAIL PROTECTED] writes:
It is undefined behavior [even though it works currently in every version
of Perl] and so it IS best to avoid it. What I don't understand is why
the powers-that-be
* Bernie Cosell [EMAIL PROTECTED] [2003-07-01 18:39]:
Perl is filled with multiple ways to do things and the simple
argument that you can do something similar using some other
mechanism is rarely determinative.
...but I hesitate to make ten ways to do it. -- Larry Wall
--
Regards,
Aristotle
On Tue, 1 Jul 2003 10:30:34 -0400, [EMAIL PROTECTED] wrote:
On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote:
my $id = 1 if $_ == 3;
This was an accidental feature that is now kept for backwards
compatibility, because some programmers have used it to create static
In article [EMAIL PROTECTED],
Bernie Cosell [EMAIL PROTECTED] writes:
On 1 Jul 2003 at 10:30, Ronald J Kimball wrote:
On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote:
my $id = 1 if $_ == 3;
[...]
This was an accidental feature that is now kept
10 matches
Mail list logo