#!/usr/bin/env perl -l use strict; use warnings; use GD::Graph::bars; #in my code, the value of $tb2 below is returned by another function, below is for simplicity, but this is how my string looks like. my $tb2="Date Start Time End Time Egress Sent 08-15-2013 00:22:22 00:22:29 16.53 3.85 08-15-2013 01:22:22 01:22:28 17.05 3.6 08-15-2013 02:22:23 02:22:28 16.79 3.61 08-15-2013 03:22:24 03:23:27 103.89 37.29 08-15-2013 04:22:24 04:22:26 2.1 0.18 08-15-2013 11:22:25 11:25:11 73.72 60.98 08-15-2013 12:22:25 12:27:55 146.65 133.68" ####What I tried: my @plot_data=(split '/\s+/',$tb2); for (@plot_data){ print $plot_data[1]; my @graph = ( ["$plot_data[1]"], ["$plot_data[4]"], ["$plot_data[5]"], ); } ####What I am trying to do: # my @graph = ( # [#all columns in "Egress" from $tb2, seperated by comma], # [#all columns in "Sent" from $tb2, seperated by comma], # ); for my $my_graph (GD::Graph::bars->new) { print STDERR "Processing Graph\n"; $my_graph->set( x_label => 'Timestamp', y_label => 'Data Conveyed/Sent', title => 'Conveyed Vs. Sent', long_ticks => 1, y_max_value => 200, y_tick_number => 8, y_label_skip => 2, bar_spacing => 3, shadow_depth => 4, accent_treshold => 200, transparent => 0, ); print @graph; open(IMG, '>file.gif') or die $!; binmode IMG; $my_graph->set_legend('Conveyed', 'Sent'); my $gd = $my_graph->plot(\@graph); #save_chart($my_graph, "Graph"); print IMG $gd->gif; close IMG; }