Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: perl javascript help passing varable

by winracer (Initiate)
on Oct 15, 2009 at 13:36 UTC ( [id://801352]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://801352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2025-03-18 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (57 votes). Check out past polls.