in reply to Re^2: heuristic to detect (perl) code
in thread heuristic to detect (perl) code
1) Comments:
my $count = ($line =~ s/[#] .*? \n//xms); $total += $count;
2) Strings:
$line =~ s/["'] [^'"\n] ['"]//gxms
3) use statements:
$count = ($line =~ s/use [^;]+ ;//gxms); $total += $count;
4) Here docs:
my $count = ($all_text =~ s/<<(\w+) .*? \1//gxms); $total += $count;
5) __DATA__, __END__:
Although, I would argue that if __DATA__ or __END__ appear anywhere in the text, then you couldn't go wrong by delcaring then and there that the text has perl code in it.$total++ if $all_text =~ s/(__DATA__|__END__) .*//xms;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: heuristic to detect (perl) code
by Anonymous Monk on Jan 20, 2013 at 10:25 UTC | |
Re^4: heuristic to detect (perl) code
by LanX (Saint) on Jan 20, 2013 at 10:46 UTC |
In Section
Seekers of Perl Wisdom