#!/usr/bin/perl #%studentbase is the hash, my @header = ("Name","English", "History", "Maths","Science","Geography"); $studentcount =0; while ($input =){ $input=~ s/^\s+|\s+\n$//g;#remove the heading n trailing space @subinfo = split (/\s+/,$input); $studentlist[$studentcount++]= $subinfo[0]; for ($count =1; $count <=@subinfo;$count++){ $studentbase{$subinfo[0].$header[$count-1]}=$subinfo[$count-1]; } } foreach $student(@studentlist){ print " $student fails in :"; for ($count=1;$count <=@subinfo; $count++){ if ($subinfo[$count] <= 50){ print" $header[$count]"; } } }