The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Lua - Parse variables out of Lua code.

SYNOPSIS

    use Data::Lua;

    my $vars = Data::Lua->parse("foo = 'bar'");
    my $vars = Data::Lua->parse_file('lua.conf');

DESCRIPTION

This module essentially evals Lua code and returns a hash reference. The returned hash reference contains all of the top-level variables, i.e. global variables assigned outside of any functions. It currently relies on Inline::Lua to do the actual code evaluation.

Any Lua code passed to this module should be trusted; there is no checking done to verify that the code is safe, and any top-level code (outside of functions) will be run when a parse method is called.

Methods

$class->parse($string)

Parses the given string as Lua code and returns a hashref containing all of the variables defined, including functions. Returns undef if the string could not be parsed.

Returns undef if the string is not valid (i.e. not defined, or the empty string).

An exception is raised if there was a problem parsing the string.

$class->parse_file($filename)

Like parse() but parses the given file instead of a string.

Returns undef if the filename argument is not valid (i.e. not defined, or the empty string).

An exception is raised if there was a problem opening or parsing the file.

SEE ALSO

Inline::Lua

Lua (http://www.lua.org)

LICENSE AND COPYRIGHT

Copyright (c) 2007 Michael Fowler. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Michael Fowler <mfowler@cpan.org>