open FILE, "somefile.txt" || die "Blah: $!\n"; while(){ m/^(\d+)\|/; print if(($first <= $1) and ($1 <= $last)); }