http://www.perlmonks.org?node_id=412637


in reply to Re^2: database sorter script
in thread database sorter script

Assuming it is relatively small and unsorted by default:

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

Or more succinctly on *nix:

$ grep -i -e ^Y db.file | sort

cheers

tachyon