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

$spud = "Wow"; @spud = ("idaho", "russet"); *potato = *spud; # Alias potato to spud using typeglob assignment print "$potato\n"; # prints "Wow!" print "@potato\n"; # doesn't work!!!!!
In string, @potato now must be written as \@potato at - line 5, near "@potato" Any ideas why this doesn't work? Once the typeglob assignement is made, all entities that were called "spud" should also be referred to as "potato"-the names should be freely interchangeable. This example (below) is taken right out of the leopard book (O'Reilly, Advanced Perl Programming, p.42)

Replies are listed 'Best First'.
Re: typeglob assignment question
by japhy (Canon) on Apr 16, 2002 at 19:45 UTC
    Older versions of Perl (even in the Perl 5 distro) required seeing @foo or $foo[...] before seeing "@foo". It's a weird thing, indeed. Newer Perls aren't so bitchy.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a (from-home) job
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Re: typeglob assignment question
by VSarkiss (Monsignor) on Apr 16, 2002 at 19:24 UTC

    Try:print @potato, "\n"; Or, better still: print join(' ', @potato), "\n";

Re: typeglob assignment question
by trs80 (Priest) on Apr 16, 2002 at 19:25 UTC
    It ran fine as posted for me. What version and platform are you on? I am on Linux with Perl 5.6.1
      yep, running Perl 5.6.1 (IRIX64) seems to work fine. Thanks much.