Linux.com

About those sigils...

Posted by: Administrator on July 08, 2004 07:26 PM
It's misleading to think of the sigils (@,$,%,&,*) as saying what type of variable '@values' is, and means you don't get far before having to deal with things like $values[1], and the fact that $values, @values and %values are, at least superficially, completely unrelated.

Better to start out by thinking of it as saying what type the *value* is - if it's attached to an unqualified name then the value and the variable are the same type, but if not then what comes after the name tells you; $values[1] is from the array @values, $values{1} is from the hash %values, and so on.

That way, you can read things like

  %b = @values{1,3,5,'blue'}
without risking a headache<nobr> <wbr></nobr>:)

John.

#

Return to SysAdmin to SysAdmin: Approaching Perl