I prefer to decode this kind of code from outside to inside.
1. The sigil @ indicates the result is an array
2. Thus, $var1{$var2} should be an array reference
3. The structure of $var1{$var2} suggests var1 means a hash, or %var1
4. Thus, $var2 is a key of the hash %var1
So, %var1 is a hash of
de the brackets as an array", you'd
likely be using a simpler data structure such as:
"Hash key 2" = [ "Array value 1", "Array value 2", ... ]
rather than:
"Hash key 2" = \[ "Array value 1", "Array value 2", ... ]
On 2011-06-22 18:44, josanabr wrote:
I'm reading a program written in perl and I read this statement
@{ $var1{ $var2 } }
Such variable names with numbers in them are often a sign of bad code.
What is the context?
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.or
Hi John,
On Wed, 22 Jun 2011 09:44:56 -0700 (PDT)
josanabr wrote:
> Hi,
>
> I'm reading a program written in perl and I read this statement
>
Well, assuming you are interested to learn about what @{$var1{$var2}} mean,
then:
1. $var1{$var2} is the value of the %var1 hash
> "JG" == Jim Gibson writes:
JG> See 'perldoc perlref' for information about references in Perl.
even better for a newbie is to read 'perldoc perlreftut' and later
perllol and perldsc. leave perlref for when you have some experience
with refs under your belt and want more info.
uri
--
U
cific question about the statement appearing in your title?
This one:
@{$var1{$var2}}
I can tell you that the syntax of that statement implies that %var1 is a
hash, $var2 is a scalar, the element of %var1 indexed by $var2 is
$var1{$var2} and is a reference to an array, and @{$var1{$var2}} i
On Wed, Jun 22, 2011 at 6:44 PM, josanabr wrote:
> Hi,
>
> I'm reading a program written in perl and I read this statement
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>
Without any more i
Hi,
I'm reading a program written in perl and I read this statement
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
Yun yun wrote:
>
> What is the meanings of the following two expressions?
> 1.$var1{$var2}
This is the value from the hash %var1 using the key $var2
> 2.$var1($var2)
$ perl -MO=Deparse -e'$var1($var2)'
syntax error at -e line 1, near "$var1("
This is a s
> What is the meanings of the following two expressions?
> 1.$var1{$var2}
> 2.$var1($var2)
Err... they look rather similar, don't they? :P
Basically, it works a little like:
my %hash = ( "key1" => "value1",
"key2" => "value2
What is the meanings of the following two expressions?
1.$var1{$var2}
2.$var1($var2)
_
Do You Yahoo!? µÇ¼Ãâ·ÑÑÅ»¢µçÓÊ! http://mail.yahoo.com.cn
ÎÞÁÄ£¿ÓôÃÆ£¿¸ßÐË£¿Ã»ÀíÓÉ£¿¶¼À´ÁÄÌì°É£¡¡ª¡ª
ÑÅ»¢È«ÐÂÁÄÌìÊÒ! http://cn.chat.yahoo.com/c
11 matches
Mail list logo