in reply to local() peculiarities

Recent perls have a feature (I'm not entirely sure why) that if @foo is seen in an interpolated string before any element of @foo (or the entire array itself) is used in an expression, you'll get barked at. Using the symbol *foo is not good enough, but using subscripts like $foo[0] is.

japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re: Re: local() peculiarities
by chipmunk (Parson) on Jan 22, 2001 at 09:22 UTC
    I was going to try to explain the reason for this feature, but then I thought, I bet it's in the documentation for the error message.

    `perldoc perldiag`

    In string, @%s now must be written as \@%s (F) It used to be that Perl would try to guess whether you wanted an array interpolated or a literal @. It did this when the string was first used at runtime. Now strings are parsed at compile time, and ambiguous instances of @ must be disambiguated, either by prepending a backslash to indicate a literal, or by declaring (or using) the array within the program before the string (lexically). (Someday it will simply assume that an unbackslashed @ interpolates an array.)
    So, the reason for this error message is to flag a change in the implementation that will be incompatible with earlier versions of Perl.