Hi Venu!

On Tuesday 02 Feb 2010 09:19:27 venu madhav wrote:
> Hi All,
>         I've a situation where I create a hash variable in PERL and
> use it in Java script which is embedded in the CGI. The key for that
> hash is taken from JavaScript. For ex:

Regarding "PERL" - it's either "perl" or "Perl" but never "PERL":

http://perl.org.il/misc.html#pl_vs_pl

> 
> ----- CGI code----
> my %hash{3}=300;

That's invalid Perl and you probably mean:

<<<
my %hash = (3 => 300);
>>>

Or alternatively:

<<<
my %hash;
$hash{3} = 300;
>>>

> ------JScript code---
> var var1 = 3;
> var variable = $hash{var1};

That's invalid JavaScript. You need hash[var1];

> ------------------------
>            When I run such a script, it is failing at the 3rd
> statement above. Can someone help me in resolving this?

Please go to http://perl-begin.org/ and find a good resource to learn Perl. To 
qoute Mark Jason Dominus "You can't just make shit up and expect the computer 
to magically understand what you mean, retardo!".

You can look at JSON to pass data from your Perl scripts to your JavaScript 
code:

http://search.cpan.org/search?query=json&mode=all

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to