KW Perl Mongers | Perl Modules: A Look Under the Hood | #7 |
Arrow OperatorHow do you get back the elements of an array through a reference? $a[0] = 1; ${$array_ref}[0] = 1; # same thing That looks messy. Fortunately, there's a simplification. $array_ref->[0] = 1; # same thing. note square brackets. $hash_ref->{foo} = 1; # similarly for hash. note curly brackets. $sub_ref->(@args); # similarly for subroutines. note parens. $object_ref->method(@args); # ...and similarly, for object and method.
|
<< Previous | Index | Next >> | Copyright © 2004 Daniel Allen |