Matthew Simon Cavalletto > DBIx-SQLEngine > DBIx::SQLEngine::Utility::CloneWithParams

Download:
DBIx-SQLEngine-0.93.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Source  

NAME ^

DBIx::SQLEngine::Utility::CloneWithParams - Nifty Cloner

SYNOPSIS ^

  use DBIx::SQLEngine::Utility::CloneWithParams;
  
  $clone = clone_with_parameters( $string, @replacements );
  $clone = clone_with_parameters( \@array, @replacements );
  $clone = clone_with_parameters( \%hash, @replacements );

DESCRIPTION ^

This package provides a function named clone_with_parameters() that makes deep copies of nested data structures, while making replacements in key places.

clone_with_parameters

  $clone = clone_with_parameters( $reference, @replacements );

This function makes deep copies of nested data structures, with object reblessing and loop detection to avoid endless cycles. (The internals are based on clone() from Clone::PP.)

It's one distinctive behavior is that if a data structure contains references to the special numeric Perl variables $1, $2, $3, and so forth, when it is cloned they are replaced with a set of provided parameter values. It also replaces stringified versions of those references embedded in scalar values.

An exception is thrown if the number of parameters provided does not match the number of special variables referred to.

Limitations:

Examples:

safe_eval_with_parameters

  @results = safe_eval_with_parameters( $perl_code_string );

Uses the Safe package to eval the provided code string. Uses a compartment which shares the same numeric variables, so that values evaluated this way can then be cloned with clone_with_parameters.

SEE ALSO ^

See DBIx::SQLEngine for the overall interface and developer documentation.

See DBIx::SQLEngine::Docs::ReadMe for general information about this distribution, including installation and license information.

syntax highlighting: