Peter Daum schreef:
> my $x = undef;
> foreach ( qw(a b c) ) {
> my $t = $x if $x;
> warn( "\$t == ", $t||'undef', "\n" );
> $t = $_;
> }
>
> $t would be initialized with the value of $x if that was true;
> otherwise (at least that's what I would expect) $t should be
> undefined,
> so
Chas. Owens wrote:
On Jan 13, 2008 1:20 PM, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
Statements don't define scope, braces and files define scope.
snip
so why should you be able to use it because it has been changed to this
my $t = $x if $x;
print "$t\n";
You can use it because it is i
On Jan 13, 2008 1:20 PM, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
> Statements don't define scope, braces and files define scope.
snip
> > so why should you be able to use it because it has been changed to this
> >
> > my $t = $x if $x;
> > print "$t\n";
>
> You can use it because it is in th
Chas. Owens wrote:
On Jan 13, 2008 6:22 AM, Peter Daum <[EMAIL PROTECTED]> wrote:
snip
my $t =$x if $x;
snip
$t would be initialized with the value of $x if that was true;
otherwise (at least that's what I would expect) $t should be undefined,
so the result would be as before. The real out
On Jan 13, 2008 6:22 AM, Peter Daum <[EMAIL PROTECTED]> wrote:
snip
> my $t =$x if $x;
snip
> $t would be initialized with the value of $x if that was true;
> otherwise (at least that's what I would expect) $t should be undefined,
> so the result would be as before. The real outcome, however, i
Peter Daum wrote:
Hi,
Hello,
I just got bitten by a very simple issue, where Perl behaves totally
different from what I had expected;
According to the documentation, lexical variables are visible only after
the line they have been declared in; they may be initialized;
otherwise their value i
Hi,
I just got bitten by a very simple issue, where Perl behaves totally
different from what I had expected;
According to the documentation, lexical variables are visible only after
the line they have been declared in; they may be initialized;
otherwise their value is undefined, so the following
Tom is very right.It's a closure indeed.:-)
-Original Message-
>From: Tom Phoenix <[EMAIL PROTECTED]>
>Sent: Mar 1, 2006 7:20 AM
>To: Timothy Johnson <[EMAIL PROTECTED]>
>Cc: beginners@perl.org
>Subject: Lifetime of my() variables
>
>On 2/28/06, Tim
An important distinction. Thanks.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Tom Phoenix
Sent: Tuesday, February 28, 2006 3:21 PM
To: Timothy Johnson
Cc: beginners@perl.org
Subject: Lifetime of my() variables
On 2/28/06, Timothy Johnson <[EM
On 2/28/06, Timothy Johnson <[EMAIL PROTECTED]> wrote:
> If you declare a variable with my(), it only exists within the current
> scope
Not to be too picky, but it's more accurate to say that it's the
variable's *name* that's restricted to the given scope. The variable
itself exists so long as th
t: Tuesday, May 14, 2002 5:08 PM
To: '[EMAIL PROTECTED]'
Cc: HENRY,MARK (HP-Roseville,ex1)
Subject: Re: 'my' variables
Jonathan,
Thanks for the reply..
>use strict;
>Always, always, declare your variables with my.[1] What do you mean by
"function" variabl
Jonathan,
Thanks for the reply..
>use strict;
>Always, always, declare your variables with my.[1] What do you mean by
"function" variables?
Ok, I understand you mean use 'my' to declare containers for incoming arg
variables - what about variables used just within the function - ought they
be
> Assuming I used unique variable names throughout my entire program, then is
> if correct to say I don't need to declare function variables with 'my'?
use strict;
Always, always, declare your variables with my.[1] What do you mean by "function"
variables? If you are suggesting "pass by global
Hi All,
Assuming I used unique variable names throughout my entire program, then is
if correct to say I don't need to declare function variables with 'my'?
I'm trying to figure out what advantage they give, apart from avoiding name
collision (and some speed?).
On the same note, is it generally
On Nov 8, Arul, Rex said:
>use strict;
>my $a= 2;
>print "a val is $a\n";
>my $a= 10;
>print "a val is $a\n";
>
>My question is. How can I put a 'seat-belt' as to tag this kind of
>inadvertent behavior as unacceptable?
>
>When I use, 'use warnings' pragma, it warns me. Is there anything
In Javascript you cannot declare same variable twice within the same
scope. However, I noticed that I can do that in Perl.
use strict;
my $a= 2;
print "a val is $a\n";
my $a= 10;
print "a val is $a\n";
My question is. How can I put a 'seat-belt' as to tag this kind of
inadvertent behavi
16 matches
Mail list logo