if ( $line =~ /[^\s]XY/ ) { ... } #### while ( ) { next if /^\s/; # process lines without leading whitespace here ... }