hi i just a new be to perl and i trying to put mycode into subroutines and i having trouble passing two arrays and threre scalars to a subroutine i no it prob something simple.. heres my code:
use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Socket; use Net::SNMP; use GD::Graph::lines; #function to print out a graph to screen using gd::graph sub print_graph#prints the graph to screen { my $q = new CGI; my ($xarray,$values,$xlabel,$ylabel,$title) = shift(@_); my @data = ($xarray,$values); my $graph = new GD::Graph::lines(500,350); $graph->set ( x_label => $xlabel, y_label => $ylabel, title => $title, x_label_skip => 'auto', y_label_skip => 'auto', line_width => 1, y_tick_number => 8, x_labels_vertical => 1, x_label_position => 1/2, transparent => 0, ); my $gd_image = $graph->plot(\@data); print $q->header(-type => "image/png"); binmode STDOUT; print $gd_image->png; } my $graphxlabel = "Time"; my $graphylabel = "No. Of Packets Recieved"; my $graphtitle = "No. Of Packets Recieved On Interface"; #function call print_graph(\@x_axis_array,\@values_array,\$grap +hxlabel,\$graphylabel,\$graphtitle);
where the two arrays @x_axis_array and @values_array have been previously filled in a while loop this code had been working before i tried to put it in a while loop so i no that the values are been filled into the arrays properly.. tanx in advance tommycahir

In reply to 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.