1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
use strict;
use warnings;
use Text::CSV;
use GD::Graph::bars;
use GD::Graph::Data;
my $filename = "out.csv";
my $input1 = 'f1.txt';
my $input2 = 'f2.txt';
open( OUT1, '>' . $input1 ) or die("can't open $input1. \n");
open( OUT2, '>' . $input2 ) or die("can't open $input2. \n");
sub main {
print "Entrez la valeur : ";
my $val;
chomp( $val = <STDIN> );
open( INPUT, $filename ) or die "Cannot open $filename";
my $line = <INPUT>;
print "les pays ou les accident sont a cause de la TraFic sont :";
while ( $line = <INPUT> ) {
chomp($line);
my (
$name, $name2, $purcent, $purcent1,
$purcent2, $purcent3, $purcent4, $purcent5
) = split( ' ', $line );
if ( $name2 > $val ) {
print "$name\t$name2\t\n";
print OUT1 "$name\n";
print OUT2 "$name2\n";
print "\n";
}
}
}
sub graph{
my $data = GD::Graph::Data->new([
["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
]) or die GD::Graph::Data->error;
my $graph = GD::Graph::bars->new;
$graph->set(
x_label => 'X Label',
y_label => 'Y label',
title => 'A Simple Bar Chart',
#y_max_value => 7,
#y_tick_number => 8,
#y_label_skip => 3,
#x_labels_vertical => 1,
#bar_spacing => 10,
#shadow_depth => 4,
#shadowclr => 'dred',
#transparent => 0,
) or die $graph->error;
$graph->plot($data) or die $graph->error;
my $file = 'bars.png';
open(my $out, '>', $file) or die "Cannot open '$file' for write: $!";
binmode $out;
print $out $graph->gd->png;
close $out
}
main(); |
Partager