#! perl -sw use strict; local $"='';#" my ($tmp1, $tmp2); for my $lines (0..5) { my $willmatch = ((qq(@{[0..9]}) x 4).$/)x $lines; my $half = int($lines/2); my $wontmatch = ((qq(@{[0..10]}) x 4).$/)x$half . 'X' . ((qq(@{[0..9]}) x 4).$/)x(1+$lines-$half); for ($willmatch, $wontmatch) { # if the number of lines inthe string is less than 4 if( ($tmp1=()=m/\n/mg) <=4 # and they are all < 40 chars and ( $tmp2=()=m/^(?:[^\n]{0,40}\n)/mg ) == $tmp1 ) { print "\nMatches! ($tmp1 lines with $tmp2 < 40 chars)\n"; } else { print "\nNo Match! ($tmp1 lines with only $tmp2 < 40 chars)\n"; } print $_.$/; } } __END__