http://www.perlmonks.org?node_id=851354


in reply to database using associative has

You may need something like this UNTESTED:

#!/usr/bin/perl use warnings; use strict; my @header = qw( English History Maths Science Geography ); my %studentlist; while ( <> ) { my ( $name, @subinfo ) = split; @{ $studentlist{ $name } }{ @header } = @subinfo; } foreach my $student ( keys %studentlist ) { print " $student fails in :", join( ' ', grep $studentlist{ $stude +nt }{ $_ } <= 50, @header ), "\n"; }

Replies are listed 'Best First'.
Re^2: database using associative has
by changma_ha (Sexton) on Jul 27, 2010 at 08:52 UTC

    Thanks jwkrahm .... can u plz explain the following lines

    @{ $studentlist{ $name } }{ @header } = @subinfo; and print " $student fails in :", join( ' ', grep $studentlist{ $student } +{ $_ } <= 50, @header ), "\n"; }