CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: mod_perl:
Please Help - Value not returned


New User

Oct 23, 2006, 12:03 AM

Post #1 of 2 (13723 views)
Please Help - Value not returned Can't Post

$variable2="Actual value";

If I want to retrieve the string "Actual value" I will be giving :

$$variable1 (Value of(value of(variable1)). Normally this works. If mod-perl is on, it does not return any value.

I would really be grateful for any help :(
Jobs in India
Real Estate in India

Thaumaturge / Moderator

Oct 23, 2006, 4:12 AM

Post #2 of 2 (13717 views)
Re: [sarathy] Please Help - Value not returned [In reply to] Can't Post

What you're doing here is using symbolic references. Symbolic references are a very bad idea and they should only be used very rarely.

They are such a bad idea that if you're programming with "use strict" turned on (and you should _always_ program with "use strict" turned on) then Perl turns symbolic references into compile time errors.

You very rarely have to use symbolic references (the only example I can think of is to alter the symbol table). You'll be far better off changing your code to use a hash instead.

my %vars; 
my $variable1 = 'variable2';
$vars{$variable1} = 'Actual value';

print $vars{$variable1};

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives