Tintin is at: /Users/Tintin/Documents/Programs/Perl/Perl_monks>cat -n +monk1.pl 1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 7 use Data::Dumper; 8 #use regression; 9 10 open (TEST,">xxx.txt"); 11 12 my %test = (); 13 14 my @teams = ('packers','lions','bears','vikings'); 15 my @data = (5,10,15,20); 16 17 my $counter = 1; 18 foreach my $team (@teams) 19 { 20 my $counter2 = 0; 21 foreach my $data_value (@data) { 22 $test{$team}{'raw_data'}{$counter} = $data_value; 23 print TEST "$team: $counter - $test{$team}{'raw_data +'}{$counter}\n"; 24 $data[$counter2] = $data[$counter2] * 2; 25 $counter2++; 26 $counter++; 27 } 28 } 29 30 local $\ = "\n"; # Set the output rec separator to newline 31 foreach my $team (keys %test ) { 32 foreach my $counter (keys %{$test{$team}{'raw_data'}} ) + { 33 print STDOUT $team . '{raw_data}' . $counter . ' val +ue is ' . $test{$team}{'raw_data'}{$counter}; 34 } 35 } 36 37 close (TEST); Tintin is at: /Users/Tintin/Documents/Programs/Perl/Perl_monks> Output is: Tintin is at: /Users/Tintin/Documents/Programs/Perl/Perl_monks>perl mo +nk1.pl lions{raw_data}8 value is 40 lions{raw_data}6 value is 20 lions{raw_data}7 value is 30 lions{raw_data}5 value is 10 packers{raw_data}4 value is 20 packers{raw_data}1 value is 5 packers{raw_data}3 value is 15 packers{raw_data}2 value is 10 bears{raw_data}11 value is 60 bears{raw_data}10 value is 40 bears{raw_data}9 value is 20 bears{raw_data}12 value is 80 vikings{raw_data}16 value is 160 vikings{raw_data}13 value is 40 vikings{raw_data}15 value is 120 vikings{raw_data}14 value is 80
Cheers!!!!

In reply to Re: difficulty with complicated (for me) hashes by MarkovChain
in thread difficulty with complicated (for me) hashes by o2bwise

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.