Compiler::Lexer - Lexical Analyzer for Perl5
use Compiler::Lexer; use Data::Dumper; my $filename = $ARGV[0]; open my $fh, '<', $filename; my $script = do { local $/; <$fh> }; my $lexer = Compiler::Lexer->new($filename); my $tokens = $lexer->tokenize($script); print Dumper $$tokens; my $modules = $lexer->get_used_modules($script); print Dumper $$modules;
Compiler::Lexer provides three methods
create new instance. You can create object from `$filename` in string.
get token objects includes parameter of 'name' or 'type' or 'line' and so on. This method requires perl source code in string.
get names of used module. This method requires perl source code in string.
Masaaki Goshima (goccy) <goccy(at)cpan.org>
tokuhirom: Tokuhiro Matsuno
Copyright (c) 2013, Masaaki Goshima (goccy). All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Compiler::Lexer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Compiler::Lexer
CPAN shell
perl -MCPAN -e shell install Compiler::Lexer
For more information on module installation, please visit the detailed CPAN module installation guide.