in reply to Re^2: Soft Array Refs
in thread Soft Array Refs

... single quotes around '@table' ...

If double-quotes has been used, double-quotish interpolation of an array named  @table_ would have been attempted and, with strict fully enabled (as it is in Athanasius's code), would have crashed compilation. Single-quotes do not interpolate. (Update: The  @ sigil could also be escaped in double-quotes.)

c:\@Work\Perl\monks>perl -le "use warnings; use strict; ;; print qq{@table}; " Possible unintended interpolation of @table in string at -e line 1. Global symbol "@table" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors. c:\@Work\Perl\monks>perl -le "use warnings; use strict; ;; my @table = qw(fee fie foe); ;; print qq{double-quote array interpolation: (@table)}; ;; print q{single-quote, no interpolation: (@table)}; ;; print qq{double-quote, sigil escaped: (\@table)}; " double-quote array interpolation: (fee fie foe) single-quote, no interpolation: (@table) double-quote, sigil escaped: (@table)

Update: Changed code examples to consolidate compiling code examples into single group of statements.


Give a man a fish:  <%-(-(-(-<

Replies are listed 'Best First'.
Re^4: Soft Array Refs
by smknjoe (Beadle) on Jun 25, 2015 at 15:30 UTC

    Correct.

    I noticed this after it failed the first time and I looked closer at Athanasius's code. Gvim's context-sensitive color-coding also clued me in to what was going on.

    As a follow-up, I was very successful in coding this as a nested hash - it took very little time and I was quite pleased at how easy it was. It was far less code than my previous attempt using if-statements and arrays AND no soft references!