Welcome to the monastery. When passing multiple non-scalar variables into a sub the arguement list gets flattened into a scalar list. This is why you must use references. perlref should be a good starting place to learn about references. FYI when returning values from a sub, the same rules apply. i.e. a sub that you needed to pass two arrays and a hash to would look like this.

myMultipleArgSub(\@first,\@second,\%third);
Forgive my previous answer. You do not need to use the shift function in conjuction with assigning the argument list. shift with out any arguments will take the first element off of the @_ array and return it as a scalar. The code  my ($xarray,$values,$xlabel,$ylabel,$title) = shift(@_); does not do what you expect. Two ways of doing it are
my $xarray = shift; my $xarray = shift; my $values = shift; my $xlabel = shift; my $ylabel = shift; my $title = shift;
This is really a bad way of getting this done...for that.. God gave us this method my ($xarray,$values,$xlabel,$ylabel,$title) = @_; This puts your scalars in list context and assigns the @_ list to it matching indexes to the order of the decalared variables. This is a good general purpose way to get this done.

The code my @data = ($xarray,$values); probably doesn't do what you expect either. This will assign two array refs (assuming these are array refs) to @data if you want to assign the values of those arrays to @data you could
push @data,$_ for @{$xarray}; push @data,$_ for @{$values};
Not trying to nit pick at all .. but just trying to point out something that may not be what you had intended.
After delving a little more into GD::Graph documentation I see you are doing what it expects here. Also drop
use strict; use warnings;
in the top of your script. For me its a good bonehead error catcher. Alot of the silly things we do get caught by those two pragma. Hope some of that was useful... again sorry for previous answer.

Grygonos

In reply to Re: passing multiple items to a subroutine by Grygonos
in thread passing multiple items to a subroutine by tommycahir

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.