Data::Dumper::LispLike - Dump perl data structures formatted as Lisp-like S-expressions
version 0.004
use Data::Dumper::LispLike; print dumplisp [ 1, 2, [3, 4] ]; # prints "(1 2 (3 4))\n";
Indentation string. Default is " " (four spaces).
Maximum width of s-expression that is considered "simple", i.e. that fits into one line and does not need to be split into many lines. Default is 60.
my $listref = ...; print dumplisp $listref;
This function converts an ARRAYREF, which may contain strings or other ARRAYREFs, into Lisp-like S-expressions. The output is much compacter and easier to read than the output of Data::Dumper.
ARRAYREF
Data::Dumper
Here is a bigger real-life example of dumplisp() output:
(COMMA (AND (CMDDEF -writeln (%str) (BLOCK (CMDRUN -write '%str\n'))) (CMDDEF -writeln1 (%STR) (BLOCK (CMDRUN -write1 '%STR\n'))) (CMDDEF -warn (%WARN_MESSAGE) (BLOCK (CMDRUN -warnf '%WARN_MESSAGE\n'))) (CMDDEF -abort () (BLOCK (CMDRUN -exit 1))) (CMDDEF -die (%DIE_MESSAGE) (BLOCK (COMMA (CMDRUN -warn %DIE_MESSAGE) (CMDRUN -abort)))) (IF (OPTION (COMPARE != %UNAME/SYSNAME Linux) (CMDRUN -die 'pfind is only for linux'))) (CMDDEF -kill () (BLOCK (CMDRUN -signal KILL))) (CMDDEF -term () (BLOCK (CMDRUN -signal TERM))) (CMDDEF -hup () (BLOCK (CMDRUN -signal HUP))) (CMDDEF -ps () (BLOCK (CMDRUN -exec ps uf '{}'))) (CMDDEF pso (%PS_FIELDS) (BLOCK (CMDRUN -exec ps '\q-o' %PS_FIELDS '{}'))) (CMDDEF -exe (%exe_arg) (BLOCK (COMPARE == %exe %exe_arg))) (CMDDEF -cwd (%cwd_arg) (BLOCK (COMPARE == %cwd %cwd_arg))) (ASSIGN %vsz %statm/size) (ASSIGN %rss %statm/resident) (CMDDEF -kthread () (BLOCK (COMPARE == 0 %rss))) (CMDDEF -userspace () (BLOCK (NOT (CMDRUN -kthread)))) (ASSIGN %ppid %stat/ppid) (ASSIGN %comm %stat/comm) (ASSIGN %nice %stat/nice) (ASSIGN %nice_flag (CONDITIONAL (OPTION (COMPARE -lt %nice 0) '<') (OPTION (COMPARE -gt %nice 0) N) (DEFAULT ''))) (ASSIGN %s %stat/state) (ASSIGN %state %s%nice_flag) (ASSIGN %name %status/Name) (CMDDEF -grep (%GREP_ARG) (BLOCK (OR (COMPARE -m %exe '*%GREP_ARG*') (COMPARE -m %comm '*%GREP_ARG*') (COMPARE -m %name '*%GREP_ARG*')))) (CMDDEF -egrep (%EGREP_ARG) (BLOCK (OR (COMPARE '=~' %exe %EGREP_ARG) (COMPARE '=~' %comm %EGREP_ARG) (COMPARE '=~' %name %EGREP_ARG)))) (ASSIGN %command %tree%name) (CMDDEF -pstree () (BLOCK (AND (CMDRUN -settree) (CMDRUN -echo %ppid %pid %state %command))))) (AND (BLOCK (OR (CMDRUN -userspace) (COMPARE == %pid 23))) (CMDRUN -head 10) (CMDRUN -echo %pid %ppid %stat/ppid) (CMDRUN -ps)))
http://github.com/spiculator/data-dumper-lisplike
Sergey Redin <sergey@redin.info>
This software is copyright (c) 2013 by Sergey Redin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::Dumper::LispLike, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Dumper::LispLike
CPAN shell
perl -MCPAN -e shell install Data::Dumper::LispLike
For more information on module installation, please visit the detailed CPAN module installation guide.