IO::Tokenized::File - Extension of IO::File allowing tokenized input
my $fh = IO::Tokenized::File->new(); $fh->setparser([num => qr/\d+/], [ident => qr/[a-z_][a-z0-9_]], [op => qr![+*/-]!,\&opname]); $fh->open('tokenfile') || die "Can't open 'tokenfile': $1"; while ($t = $fh->gettoken()) { ... do something smart... } $fh->close();
IO::Tokenized::File adds the methods provided by IO::Tokenized to IO::File objects. See IO::Tokenized for details about how the tokens are specified and returned.
IO::Tokenized::File inherits both from IO::tokenized and IO::File, so that methods from both classes are available to IO::Tokenized::File objects.
IO::Tokenized::File redefines the following methods:
new([$filename[,@tokens]])
The new method is redefined so as to call both IO::File::new (passing to $filename if it is defined) and IO::Tokenized::new (passing to it the @tokens parameter).
new
IO::File::new
$filename
IO::Tokenized::new
@tokens
open($filename)
The open method from IO::File is redefined so that only opening for input is allowed: requestes for other kind of opening are silently converted to oepning for input (this is a bug).
open
IO::Tokenized and IO::File.
Leo Cacciari, <hobbit@cpan.org>
Copyright 2003 by Leo Cacciari
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install IO::Tokenized, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Tokenized
CPAN shell
perl -MCPAN -e shell install IO::Tokenized
For more information on module installation, please visit the detailed CPAN module installation guide.