perl -le '$_ = "\n"; print /^$/' 1 #### # 1 2 3 4 5 6 #23456789012345678901234567890123456789012345678901234567890123456789 map{$n=$o=$_;for$c(@_){$n+=s/$c//}/^$/&&push@{$w[$n]},$o};@{pop@w} #### #!/usr/bin/perl -wT use strict; my @arr = ("\n","dog\n","cat\n"); my $patternmatch = 0; my $underscorematch = 0; /^$/ && $patternmatch++ for @arr; $_ || $underscorematch++ for @arr; print "Patternmatch = $patternmatch\n"; # <== prints 1 print "Underscorematch = $underscorematch\n"; # <== prints 0