use strict; use warnings; sub get_schoolname { my $id_to_fetch = $_[0]; local *SCHOOLDATA; open(SCHOOLDATA,"school_data.pdt") or die "Can't open school data file: $!"; while ( ) { my ($id, $name) = split /\|/; return $name if $id eq $id_to_fetch; }; };