Dear Monks,

I have used a hash table with several values for the same key but I would like to display the results in a slightly different way my program currently gives. Could you check this ? Thanks a lot

Here are the results

EG2;100;22/10/2006;0.185416666666667;04:21:45;C; EDD;100;22/10/2006;0.207428571428572;02:30:02;W; 04:00:00;W; EGC;80;22/10/2006;0.284926470588235;05:58:56;S;
Here what I would like
EG2;100;22/10/2006;0.185416666666667;04:21:45;C; EDD;100;22/10/2006;0.207428571428572;02:30:02;W; ;;;;04:00:00;W; EGC;80;22/10/2006;0.284926470588235;05:58:56;S;

Here is my program (tested with $week = W42)

my $KPIs_fa_infile = "KPIs_fa_TACT_${week}.csv"; open my $KPIs_fa_INFILE, q{<}, $KPIs_fa_infile or die; my $capa_fa_infile = "all_capa_fa_${week}.csv"; open my $capa_fa_INFILE, q{<}, $capa_fa_infile or die; my $KPIs_fa_outfile_with_capa_infos = "KPIs_fa_TACT_${week}_capa.csv"; open my $KPIs_fa_OUTFILE_capa, q{>}, $KPIs_fa_outfile_with_capa_infos +or die; my %KPI; while(my $line = <$KPIs_fa_INFILE>){ $line =~ s/\s+$//; my @Elements = split /;/, $line; # on enlève le premier element my $reg = shift(@Elements); $KPI{$reg}= join ";", @Elements; } close $KPIs_fa_INFILE; my %capa; while(my $line = <$capa_fa_INFILE>){ $line =~ s/\s+$//; my @Elements = split /;/, $line; # on enlève le premier element my $reg = shift(@Elements); my $value = join ";", @Elements; $value = "$value;"; #print STDOUT "the value is $value\n"; push( @{$capa{$reg}}, $value ); } close $capa_fa_INFILE; my @KEYS = keys %KPI; my $key; foreach $key(@KEYS){ if (exists $capa{$key}){ #print $KPIs_fa_OUTFILE_capa $KPI{$key} $capa{$key}; print $KPIs_fa_OUTFILE_capa "$key;$KPI{$key};@{$capa{$key}}\n"; } } close $KPIs_fa_OUTFILE_capa;

Here is KPIs_fa_TACT_W42.csv

EDD;100;22/10/2006;0.207428571428572 EKR;80;22/10/2006;0.0956081081081081 EG2;100;22/10/2006;0.185416666666667 LFP;100;22/10/2006;0.330322580645161 EGC;80;22/10/2006;0.284926470588235

Here is all_capa_fa_W42.csv

E2F;07:51:21;T EDD;02:30:02;W EDD;04:00:00;W EG1;10:24:42;C EG2;04:21:45;C EGC;05:58:56;S

In reply to display correction by steph_bow

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.