foreach my $line (@array){ chomp $line; next unless (defined $line && $line ne ''); my @t = split /\s+/, $line; if ( scalar @t =~ /^[a-zA-Z0-9]/){ print "CCODE: $line\n"; } else { print "NO : $line\n"; } }