# Change these to the actual column widths. Use a star at the end to get the rest. my @column_widths = (###, ###, '*'); my $unpack_spec = join ' ', map { "A$_" } @column_widths; my %codes; while () { chomp; my ($desc, $code, $other_thingy) = unpack $unpack_spec, $_; # If you want to remove the pre-pended whitespace on the description ... $desc =~ s/^\s+//; $codes{$code} = { Description => $desc, Other_Thing => $other_thingy, }; } my $choice = 'GMT'; print "$choice: $codes{$choice}{Description}\n";