Constructs

    • You can do C-style for loops,but you often don't need them
    • Don't use them where a foreach will do
    • Don't use them where a while will do
    • Create an anonymous array reference, and assign it:
    • This is "anonymous" because we didn't have to create an array
    • Hashes have a similar constructor
    • Treat as you'd otherwise treat a reference
      • Single quotes: 'text' => q/text/
      • Double quotes: "text" => qq/text/
      • Backticks: => qx/text/
      • Regex match (m//), Regex substitute (s///), and translate (, y///) work the same way
    • You can use any character except whitespace.
    • But use something balanced like parens or braces
    • Declare global variables with use vars.
    • Declare lexical variables with
    • local is not what you think, use my instead unless you know why you're using local
    • Use only when your package needs a global variable