Printing % value autside the loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arifgroup
    New Member
    • Jun 2012
    • 1

    Printing % value autside the loop

    unable to print the % values outside the loop


    foreach(@pushar ray)
    {
    $_=~ s/(\s)*$//;

    %diskraid_Info = split(/\s*: /, $_);
    %diskraid_Info_ final = %diskraid_Info;
    }

    while ((my($k,$v))=ea ch(%diskraid_In fo_final)){
    print "[$k]<----[$v]\n";
    }
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    %diskraid_Info_ final is being overwritten on each iteration of the foreach loop. So, outside of the loop it will only contain the data from the last iteration of the foreach loop.

    You have several options.
    1) make %diskraid_Info_ final an array of hashes
    2) print the data in the foreach loop instead of building a new hash
    3) take a couple steps back and in your process and redesign how your compiling your data

    Comment

    Working...