There's a lot about your post I don't understand, and I have no experience whatever with the URI::GoogleChart module, but I have never thought that mere ignorance should prevent one from offering advice, so here goes.

First off, I assume the

my $chart = URI::GoogleChart->new("lines", 300, 100, data => [45, 80, 55, 68], range_show => "left", range_round => 1, );
statement works as it stands (possibly an example from documentation), and your problem is to use different data than 45, 80, 55, 68.

... my data is an array or array_ref without comma, like: @a = (1 2 3 4) ...

As you have seen, this doesn't work because it is syntactically incorrect. The correct assignment expression would be  @a = (1, 2, 3, 4) or perhaps a statement like
    my @a = (1, 2, 3, 4);
if one were defining a lexical array (see my) and initializing it. The quick fix is to put in the needed commas.

But I suspect the quick fix doesn't work because your data is not in the form of a list, but rather is a string consisting of numbers with whitespace separating the numbers, something like  "1 2 3 4" (with the  " double-quotes being an essential part of the expression), e.g.,
    my $data = "1 2 3 4";

If so, the question becomes "How do I convert a string in the format '1 2 3 4' into a list that I can assign to an array?" The split Perl built-in function can do just this with a string in this format. (Use something like Data::Dumper or Data::Dump to confirm your intermediate results.)

>perl -wMstrict -le "use Data::Dumper; ;; my $data = '1 2 3 4'; my @a = split /\s+/, $data; print Dumper \@a; " $VAR1 = [ '1', '2', '3', '4' ];

Now you have an array from which you can take a reference:  my $array_ref = \@a;
This reference could be used in the  new() constructor of URI::GoogleChart:  data => $array_ref,
or else the result of the referencing operation could be used directly:  data => \@a,
or else the array itself could be expanded within an anonymous array constructor:  data => [ @a ],

I hope that helps. Update: Oh, and please pay attention to kcott's good advice about effective question-posting and the use of strict and warnings!


In reply to Re: draw picture by google Chart by AnomalousMonk
in thread draw picture by google Chart by HHCHANG

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.