in reply to Dynamically Building Variable Names

It should be quite straighforward:
sub foo { my $basename = $_[0] . $_[1]; my $addon = '0'; while (defined($(my $goodname = "$basename$addon")) { $addon++; } my $$goodname = $_[2]; return $goodname; }
untested, but
$name = foo('example','other', 49); print $$name . "\n";
should print 49 and put 49 in variable $exampleother0

Update: I use symbolic variables quite a bit for reusable code, but I agree with Fletch that you should learn to use data structures first.

2 made the code function correctly... :D

Replies are listed 'Best First'.
Re^2: Dynamically Building Variable Names
by merlyn (Sage) on Apr 22, 2005 at 17:16 UTC
    No. Don't do that. You really don't want to do that. Really not. Don't let your data become code, or code become data. That's the way to harder bugs to debug, or potential security holes.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.