#!/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{ $student }{ $_ } <= 50, @header ), "\n"; }