#!/usr/bin/perl -l print for map { substr($_, 1) } sort map { ( /blahblah/ ? 0 : 1 ) . $_ } <>;