in reply to Counting devices types, device sizes and number of devices.

I'd use a hash, keyed on raid type and device size. You only need one value then: the count:
$count{$raid_type}{$device_size}++;
or
$count{$raid_type,$device_size}++;

Replies are listed 'Best First'.
Re^2: Counting devices types, device sizes and number of devices.
by Anonymous Monk on Jan 03, 2012 at 07:45 UTC

    Hi JavaFan,

    That's neat. Now I just need to figure out a way to get those values inside the hash.

    Perlpetually Indebted To PerlMonks

      use Data::Dumper; while (<DATA>) { chomp; @F = split /\t/; # <== place proper delimiter or regex $devices{$F[4]}{$F[-1]}++; } $Data::Dumper::Sortkeys = 1; print Dumper \%devices; # accessing for $type (sort keys %devices) { for $size (sort {$a <=> $b} keys %{$devices{$type}}) { print "$type $size $devices{$type}{$size} \n"; } }
      - J

        Hi Jaimon,

        Thanks a lot. But thing is, the output given in my post is output of a command.Does Data Dumper have the facility to take in command output?

        Perlpetually Indebted To PerlMonks