#!/usr/bin/perl use strict; use warnings; use diagnostics; use Cwd; # input files to work on my $file= "$ARGV[0]"; open INFILE, '<', $file, or die "Can't open $file : $!"; my %aircraftID; while (my $line = ){ chomp($line); my @Elements = split ';', $line; # the command shift takes away the first element of the table and stocks it in a variable my $aircraft_id = shift(@Elements); # the element of the first column (the aircraft_id) has been taken from Elements # a hash table cannot contain lists # that's why a reference to a list is needed # this reference is called by the antislash \ my $row = \@Elements; push @{$aircraftID{$aircraft_id}}, @{$row}; print STDOUT "la row2 vaut @{$row}\n"; } close INFILE; print STDOUT "\n"; foreach my $cle (keys %aircraftID){ print STDOUT "the value of $cle is : \n"; print STDOUT "@{$aircraftID{$cle}}\n"; } #### DAL11;DAL12;DAL;B772;KATL;EGKK;22:05;1325;05:39;339 SHT8K;SHT9Y;SHT;B752;EGPH;EGLL;18:00;1080;18:55;1135 SHT8K;SHT9P;SHT;B752;EGPH;EGLL;17:42;1062;18:37;1117 SHT8K;SHT9B;SHT;B752;EGPH;EGLL;10:55;655;11:49;709