in reply to scalar symbolic reference to variables

$name=chr(97); $$name=1; # shall set $a to 1 print "$$name\n"; print "$a\n";
results in:
1 1
so it DOES work.

But don't use $a and $b, they're used by sort.

see

perldoc -f sort perldoc perlvar

Actually, you almost never need symbolic references at all....

-- Joost downtime n. The period during which a system is error-free and immune from user input.

Replies are listed 'Best First'.
Re: Re: scalar symbolic reference to variables
by khippy (Scribe) on May 24, 2002 at 17:32 UTC
    Silly me misinterpreted the output of my testsnippet,
    so fool me for that ;)

    Thanx to all answers especially Joost warning about
    using $a !

    To tell the whole story read this:

    I am working on a cgi producing a two framed set. the
    left frame is showing a dynamically list of links,
    which should be anchored to jump to the letter you
    want by clicking on a link at the right frame.

    so here's what I experimented with:
    for $loop (1 .. $last_id) { for $count ( 97 .. 122) { $bla=chr($count); if ( ($list[1+($loop-1)*2]=~/^$bla/i) and (! $$bla) ) { $$bla="<a name=\"$bla\"></a>\n"; print $$bla; } } }
    I intend to puplish the whole code when it's finished
    an working. It is a database for managing your
    video-cds.

    --
    there are no silly questions
    killerhippy