Re: Please explain @{$y}

2008-01-24 Thread Chas. Owens
On Jan 24, 2008 7:49 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: snip > >> Of course. Thanks Chas. I think the docs could do with a tweak here. > > > > They seem fine to me: > > > > from perldoc strict > >"strict refs" > > This generates a runtime error if you use symbolic referen

Re: Please explain @{$y}

2008-01-24 Thread Rob Dixon
Chas. Owens wrote: > On Jan 23, 2008 10:29 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: >> Chas. Owens wrote: On Jan 23, 2008 10:07 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: Along these lines, can someone explain to me why use strict 'vars'; my $name = 'data'; print foreach @$name; p

Re: Please explain @{$y}

2008-01-23 Thread Gunnar Hjalmarsson
Chas. Owens wrote: Gunnar Hjalmarsson wrote: Chas. Owens wrote: On Jan 23, 2008 10:07 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: Along these lines, can someone explain to me why use strict 'vars'; my $name = 'data'; print foreach @$name; produces no error, when use strict 'vars';

Re: Please explain @{$y}

2008-01-23 Thread Chas. Owens
On Jan 23, 2008 10:34 PM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: snip > >>use strict 'vars'; > >>my $name = 'data'; > >>print foreach @$name; snip > Don't think so, Chas. It's > > use strict 'refs'; > > that captures symbolic references, not 'vars'. snip He was referring t

Re: Please explain @{$y}

2008-01-23 Thread Chas. Owens
On Jan 23, 2008 10:29 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > Chas. Owens wrote: > > > > On Jan 23, 2008 10:07 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > >> > >> Along these lines, can someone explain to me why > >> > >>use strict 'vars'; > >>my $name = 'data'; > >>print foreach @

Re: Please explain @{$y}

2008-01-23 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Jan 23, 2008 10:07 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: Along these lines, can someone explain to me why use strict 'vars'; my $name = 'data'; print foreach @$name; produces no error, when use strict 'vars'; print foreach @data; does? snip Because

Re: Please explain @{$y}

2008-01-23 Thread Rob Dixon
Chas. Owens wrote: > On Jan 23, 2008 10:07 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: >> Along these lines, can someone explain to me why use strict 'vars'; my $name = 'data'; print foreach @$name; produces no error, when use strict 'vars'; print foreach @data; does? Becaus

Re: Please explain @{$y}

2008-01-23 Thread Gunnar Hjalmarsson
Rob Dixon wrote: Along these lines, can someone explain to me why use strict 'vars'; my $name = 'data'; print foreach @$name; produces no error, when use strict 'vars'; print foreach @data; does? Because in the first case, the variable you use had been declared, and you hadn't

Re: Please explain @{$y}

2008-01-23 Thread Chas. Owens
On Jan 23, 2008 10:07 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > Along these lines, can someone explain to me why > >use strict 'vars'; >my $name = 'data'; >print foreach @$name; > > produces no error, when > >use strict 'vars'; >print foreach @data; > > does? snip Because us

Re: Please explain @{$y}

2008-01-23 Thread Rob Dixon
Along these lines, can someone explain to me why use strict 'vars'; my $name = 'data'; print foreach @$name; produces no error, when use strict 'vars'; print foreach @data; does? Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: Please explain @{$y}

2008-01-23 Thread Chas. Owens
On Jan 23, 2008 7:07 PM, Juan Luis Belmonte <[EMAIL PROTECTED]> wrote: snip > If you 'call' @{$y} you are using the array with the content of $y as > name of the array. snip Yeah, that is a bad practice called symbolic references left over from before we had real references. Modern Perl code use

Re: Please explain @{$y}

2008-01-23 Thread Juan Luis Belmonte
Chas. Owens wrote: > On Jan 22, 2008 8:45 PM, bootleg86 bootleg86 <[EMAIL PROTECTED]> wrote: I came across this construct foreach $i ( @{$y} ) { #do something } Is @ referring to some default array that doesn't need to be declared? Also it's using the associative version of an array? I al

Re: Please explain @{$y}

2008-01-22 Thread Chas. Owens
On Jan 22, 2008 9:33 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: snip > > If the code works (and it isn't guarenteed to) > > I'm not sure what you mean here. It's as guaranteed to work as any other > Perl code snippet I've seen. snip I mean that the following is an error. my $foo = 5; my @array = @{

Re: Please explain @{$y}

2008-01-22 Thread Rob Dixon
Chas. Owens wrote: > On Jan 22, 2008 8:45 PM, bootleg86 bootleg86 <[EMAIL PROTECTED]> wrote: I came across this construct foreach $i ( @{$y} ) { #do something } Is @ referring to some default array that doesn't need to be declared? Also it's using the associative version of an array? I alwa

Re: Please explain @{$y}

2008-01-22 Thread Chas. Owens
On Jan 22, 2008 8:45 PM, bootleg86 bootleg86 <[EMAIL PROTECTED]> wrote: > Hi, > > I came across this construct > foreach $i ( @{$y} ) { > #do something > } > > Is @ referring to some default array that doesn't need to be declared? > > Also it's using the associative version of an array? > I alway

Re: Please explain @{$y}

2008-01-22 Thread John W. Krahn
bootleg86 bootleg86 wrote: Hi, Hello, I came across this construct foreach $i ( @{$y} ) { #do something } Is @ referring to some default array that doesn't need to be declared? Also it's using the associative version of an array? I always thought only hashes were associative. $y is a re