in reply to Re: perl javascript help passing varable
in thread perl javascript help passing varable

thanks I have found out that the $number varable is a array in my perl script and on the page I am useing it on it has a while loop in it. the javascript part is in the head and I have it working that it picks up the 1st $number varable so I am thing that i need to pass the $number array to the javascript array. How do you pass arrays
Winracer Jack of all trades master of none http://www.helpmewithperl.com “Only a life lived for others is a life worth while” Albert Einstein “The golden rule for every business man is this: 'Put yourself in your customer’s place'” Orison Swett Marden “No person was ever honored for what he received; honor has been the reward for what he gave” Calvin Coolidge
  • Comment on Re^2: perl javascript help passing varable

Replies are listed 'Best First'.
Re^3: perl javascript help passing varable
by thunders (Priest) on Oct 16, 2009 at 15:17 UTC

    If it was an array it'd be called @number. However $number may be an array reference. If it is an array reference you can dereference it inside of a double quoted string, as in the example below.

    $number = [1,2,3]; @number = (4,5,6); print "$number @$number @number";

    prints something like this:

    ARRAY(0x814cc20) 1 2 3 4 5 6

    Perl's default behavior is to separate an arrays elements with spaces in double quoted context. If you instead wanted to separate with commas you could do something like this:

    my $comma_sep_number = join(",",@$number); print "My Array Contains: $comma_sep_number";

    prints:

    My Array Contains: 1,2,3