|
NAMEData::SExpression -- Parse Lisp S-Expressions into perl data structures.SYNOPSISuse Data::SExpression; my $ds = Data::SExpression->new; $ds->read("(foo bar baz)"); # [\*::foo, \*::bar, \*::baz] my @sexps; my $sexp; while(1) { eval { ($sexp, $text) = $ds->read($text); }; last if $@; push @sexps, $sexp; } $ds = Data::SExpression->new({fold_alists => 1}); $ds->read("((top . 4) (left . 5))"); # {\*::top => 4, \*::left => 5} METHODSnew [\%args]Returns a new Data::SExpression object. Possibly args are:
read STRINGParse an SExpression from the start of STRING, or die if the parse fails.In scalar context, returns the expression parsed as a perl data structure; In list context, also return the part of STRING left unparsed. This means you can read all the expressions in a string with: my @sexps; my $sexp; while(1) { eval { ($sexp, $text) = $ds->read($text); }; last if $@; push @sexps, $sexp; } This method converts Lisp SExpressions into perl data structures by the following rules:
LISP-LIKE CONVENIENCE FUNCTIONSThese are all generic methods to make operating on cons's easier in perl. You can ask for any of these in the export list, e.g.use Data::SExpression qw(cons consp); cons CAR CDRConvenience method for Data::SExpression::Cons->new(CAR, CDR)consp THINGReturns true iff "THING" is a reference to a "Data::SExpression::Cons"scalarp THINGReturns true iff "THING" is a scalar -- i.e. a string, symbol, or numberData::SExpression::Parser callbacksThese are for internal use only, and are used to generate the data structures returned by "read".new_cons CAR CDRReturns a new cons with the given CAR and CDRnew_symbol NAMEReturns a new symbol with the given namenew_string CONTENTReturns a new string with the given raw contentBUGSNone known, but there are probably a few. Please reports bugs via rt.cpan.org by sending mail to:bug-Data-SExpression@rt.cpan.org AUTHORNelson Elhage <nelhage@mit.edu>
Visit the GSP FreeBSD Man Page Interface. |