GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Compiler::Lexer(3) User Contributed Perl Documentation Compiler::Lexer(3)

Compiler::Lexer - Lexical Analyzer for Perl5

  use Compiler::Lexer;
  use Data::Dumper;

  my $filename = $ARGV[0];
  open my $fh, '<', $filename or die "Cannot open $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;

my $lexer = Compiler::Lexer->new($options);
create new instance. You can create object from $options in hash reference.

options list

filename
verbose : includes token of Pod, Comment and WhiteSpace
$lexer->tokenize($script);
get token objects includes parameter of 'name' or 'type' or 'line' and so on. This method requires perl source code in string.
$lexer->set_library_path(['path1', 'path2' ...])
set libraries path for reading recursively. Default paths are @INC.
$lexer->recursive_tokenize($script)
get hash reference like { 'module_nameA' => [], 'module_nameB' => [] ... }. This method requires per source code in string.
$lexer->get_used_modules($script);
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.

2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.