vadg
Technical User
- Mar 4, 2007
- 9
Been trying to figure this out and have had no luck with other forums.
here's the code:
here's the file:
Start
comments
1 1 1
2 2 2
3 3 3
4 4 4
quotes
End
Start
comments
5 5 5
6 6 6
7 7 7
8 8 8
quotes
End
Disregard what's happening in the graph code.
The issue is that if I include the chart portion within FOR and/or IF I only get the first part of the data match (111, 222, 333, 444) TWICE. So it does iterate (apparently).
If I place the graph code outside the for/if
I get the entire data (first match 1st time through; second match 2nd time through).
I've written a sizable program that depends on printing graphs at the end of each cycle. If I can't solve this I'll have to rewrite the code.
Thanks
here's the code:
Code:
use GD::Graph::linespoints;
my $data_file = "ChartdataMYBUG.txt";
open DATA, "$data_file" or die "can't open $data_file $!";
undef $/;
$_ = <DATA>;
close DATA;
$/ = "\n";
my @data = ([1,2,3], [3,4,5], [6,7,8]); ### just a valid array for the print call so the program will execute
for my $r (0 .. 1) {
if (/comments(.*?)quotes/sg) {
$all=$1;
print "all is $all\n";
}
my $g = GD::Graph::linespoints->new(100,100); ##graph starts here
$g->set(
x_label => 'X Label',
y_label => 'Y label',
title => 'Some simple graph',
y_max_value => 8,
y_tick_number => 8,
y_label_skip => 2
) or die $g->error;
my $format = $g->export_format;
open (IMG, ">BLOT$r.$format") or die $!;
binmode IMG;
print IMG $g->plot(\@data)->$format();
close IMG; ##graph ends here
}
Start
comments
1 1 1
2 2 2
3 3 3
4 4 4
quotes
End
Start
comments
5 5 5
6 6 6
7 7 7
8 8 8
quotes
End
Disregard what's happening in the graph code.
The issue is that if I include the chart portion within FOR and/or IF I only get the first part of the data match (111, 222, 333, 444) TWICE. So it does iterate (apparently).
If I place the graph code outside the for/if
I get the entire data (first match 1st time through; second match 2nd time through).
I've written a sizable program that depends on printing graphs at the end of each cycle. If I can't solve this I'll have to rewrite the code.
Thanks