Perl Language Tutorial:

Perl Language Variables

Syntax

  • my # Lexical declaration
  • our # Global declaration
  • $foo # Scalar
  • @foo # Array
  • $#foo # Array Last-Index
  • %foo # Hash
  • ${$foo} # Scalar De-Reference
  • @{$foo} # Array De-Reference
  • $#{$foo} # Array-DeRef Last-Index
  • %{$foo} # Hash De-Reference
  • $foo[$index] # Array get indexed
  • ${$foo}[$index] # Array De-Reference and get indexed.
  • $foo->[$index] # Array De-Reference and get indexed ( Simplified )
  • $foo{$key} # Hash get value for key
  • ${$foo}{$key} # Hash Dereference and get value for key
  • $foo->{$key} # Hash Dereference and get value for key ( Simplified )
  • \$x # Reference to Scalar
  • \@x # Reference to Array
  • \%x # Reference to Hash
  • =[ ] # Reference to Anonymous Array (Inline)
  • ={ } # Reference to Anonymous Hash (Inline)

Perl Language Variables Examples:

Related Perl Language Tutorial Topics:

Other Tutorial Topics:

This modified content is an extract of the original Stack Overflow Documentation released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow. This topic was created and modified by the Stack Ovedrflow Contributor.