Perl6::Slurp::Interpret - Interpret slurped files


Perl6-Slurp-Interpret documentation  | view source Contained in the Perl6-Slurp-Interpret distribution.

Index


NAME

Top

Perl6::Slurp::Interpret - Interpret slurped files

SYNOPSIS

Top

  use Perl6::Slurp::Interpret;

  my $colums = "Name, Birthdate";
  my $table  = "Customer";

  #### Use with regular file ... ####
      my $interpreted = eval_slurp( $filename );




  #### Use e.g. with Inline::Files ####
    use Inline::Files;
    my $sql = eval_slurp( \*SQL );     # Or any other token name

    # Now do something useful with $sql 

  __SQL__
  SELECT $columns
  FROM $table




DESCRIPTION

Top

WARNING: This module allows code injection. Use with Caution

Perl6::Slurp::Interpret

Perl6::Slurp::Interpret exports two functions, eval_slurp and quote_slurp. Both functions slurp in a file and quote them. eval_slurp takes the additional step of eval'ing in the caller's namespace, e.g. global symbols will be interpolated.

The module was predominantly designed with Inline::Files in mind. It can be used as seperatng content from code but not at the expense multiple external files. It is a more elegant approach to the <<"HEREDOC" practice commonly found in Perl programs.

The power of such an approach should be striking to anyone who has written scripts that interact to any number of external programs or processes. eval_slurp'd files can be passed to function or system calls.

eval_slurp passes all it's arguments to Perl6::Slurp. So it is possible to slurp anything that Perl6::Slurp slurps. Perl6::Slurp's magic works...and the result is eval'd in the current scope.

It's a one line function. That's it.

WARNING

Top

This modules presents a serious security risk since it evals an external, possibly user supplied file. Do not use this module if you:

* Do not know what you are doing.

* Cannot insure that friendliness of the slurped file or environment.

EXPORT

eval_slurp

quote_slurp

TODO

Top

* Create a quoted and an unquoted version?

** eval_slurp_quoted ... evals Perl code.

* Make the eval in the namespace more robust.

SEE ALSO

Top

Inline::Files, Perl6::Slurp, Inline::TT

AUTHOR

Top

Brown, <ctbrown@cpan.org>

COPYRIGHT AND LICENSE

Top


Perl6-Slurp-Interpret documentation  | view source Contained in the Perl6-Slurp-Interpret distribution.