nysus has asked for the wisdom of the Perl Monks concerning the following question:

This is an academic question with probably few practical consequences. Please note that I'm aware the 'use strict' pragma prevents the use of symbolic references. Still I'm curious to know why the following:
my @john = (47, 'brown', 186); my @mary = (23, 'hazel', 128); my @bill = (35, 'blue', 157); my @vitals = qw(john mary bill); print "@{$vitals[0]}";
...results in nothing getting printed. Why not "47 brown 186"? So the question is, if you really wanted to use symbolic references, what's the syntax?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot";
$nysus = $PM . $MCF;

Replies are listed 'Best First'.
(tye)Re: Symbolic references
by tye (Sage) on Jun 26, 2001 at 21:35 UTC

    Because you can't use symbolic references to access lexical variables. Drop your first three mys to see output.

            - tye (but my friends call me "Tye")
      Yup, you are dead on, bro. That did the trick. You definitely know your stuff. Where is this written by the way?

      Update: Looks like I need to get in the habit of going right to the POD first, big time. The answer is right there in Red, Green, & Blue at perlref. Let this be a lesson to all!

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot";
      $nysus = $PM . $MCF;

Re: Symbolic references
by Cirollo (Friar) on Jun 26, 2001 at 21:47 UTC
A reply falls below the community's threshold of quality. You may see it by logging in.