#!/usr/bin/perl -w my $db = '/some/file'; my $letter = 'Y'; open DB, $db or die "Can't read $db: $!\n"; my @matches; while(){ push @matches, $_ if m/^$letter/i; } close DB; print sort @matches;