Ariel Brosh (PAUSE Custodial Account) > Data-JavaScript-1.06 > Data::JavaScript

Download:
Data-JavaScript-1.06.tar.gz

Dependencies

Annotate this POD

Related Modules

Data::Dumper
IO::Socket
IO::Select
Sys::Hostname
XML::LibXML
XML::Simple
XML::Writer
Getopt::Long
File::Basename
more...
By perlmonks.org

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.06   Source   Latest Release: Data-JavaScript-1.13

NAME ^

Data::JavaScript - Perl extension for dumping structures into JavaScript code

SYNOPSIS ^

  use Data::JavaScript;
  
  @code = jsdump('my_array', $array_ref);
  $code = jsdump('my_object', $hash_ref);
  $code = hjsdump('my_stuff', $array_ref B<or> $hash_ref);

DESCRIPTION ^

This module is aimed mainly for CGI programming, when a perl script generates a page with client side JavaScript code that needs access to structures created on the server.

It works by creating one line of JavaScript code per datum. Therefore, structures cannot be created anonymously and needed to be assigned to variables. This enables dumping big structures.

The first arguement is a hashref or arrayref. Structures can be nested, circular referrencing is supported EXPERIMENTALLY only. The second argument is the name of JavaScript object to create.

hsdump also dumps HTML tags to embed the scriplet inside an HTML page.

When called in array context, the functions return an array of code lines. When called in scalar context, it returns one chunk of lines delimited by line fields.

AUTHOR ^

Ariel Brosh, schop@cpan.org. Inspired by WDDX.pm JavaScript support.

CREDITS ^

Garick Hamlin ghamlin@typhoon.lightning.net, fixing of quoting bug.

SEE ALSO ^

perl(1), WDDX.

syntax highlighting: