#!/usr/bin/perl -w use strict; #This script selects only the five-letter and six-letter words from a list of words open FH1, "all_words.txt" or die $!; open (FH2, '>>trimmed_words.txt') or die $!; while () { if (length ==5 or length==6) {print FH2 }; } #### while () { if (length ==6 or length==7) {print;} } __DATA__ 123 1234 12345 123456 1234567 12345678 ============== prints: 12345 123456