in reply to database using associative has

You store all the data in %studentbase, then use the temporary variable @subinfo (which gets repopulated for each line) to determine which line to print.

I'd say you're entire design is wrong. There's no need to store the entire database in memory. Just read a line, determine which subjects the student fails, and print a line stating the name and the subjects. Then move to the next student.