Created
April 15, 2013 06:43
-
-
Save hitode909/5386164 to your computer and use it in GitHub Desktop.
PerlのソースコードからStringだけ探して標準出力に表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # perl perl_string_ranking.pl ~/co/Plack/lib/**/**.pm | sort | uniq -c | sort -n -k 1 | |
| # Stringリテラルだけ出力する | |
| # sortすると重複を探すときに使える予定 | |
| use strict; | |
| use warnings; | |
| use PPI; | |
| use Perl6::Say; | |
| sub parse { | |
| my ($file) = @_; | |
| warn $file; | |
| my $document = PPI::Document->new($file); | |
| my $tokens = $document->find('PPI::Token::Quote'); | |
| return unless $tokens; | |
| map { | |
| $_->content; | |
| } @$tokens; | |
| } | |
| for my $file (@ARGV) { | |
| for my $token (parse($file)) { | |
| $token =~ s/\s+/ /g; | |
| say $token; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment