| 1 | package DBIx::dbMan::Extension::Eval; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'DBIx::dbMan::Extension'; | ||
| 5 | |||
| 6 | our $VERSION = '0.02'; | ||
| 7 | |||
| 8 | 1; | ||
| 9 | |||
| 10 | sub IDENTIFICATION { return "000001-000072-000002"; } | ||
| 11 | |||
| 12 | sub preference { return 0; } | ||
| 13 | |||
| 14 | sub known_actions { return [ qw/EVAL/ ]; } | ||
| 15 | |||
| 16 | sub handle_action { | ||
| 17 | my ($obj,%action) = @_; | ||
| 18 | |||
| 19 | if ($action{action} eq 'EVAL') { | ||
| 20 | if ($action{type} eq 'perl') { | ||
| 21 | my $code = $action{what}; | ||
| 22 | eval $code; | ||
| 23 | $action{action} = 'OUTPUT'; | ||
| 24 | $action{output} = $@ || ''; | ||
| 25 | } elsif ($action{type} eq 'system') { | ||
| 26 | my $code = $action{what}; | ||
| 27 | $action{action} = 'OUTPUT'; | ||
| 28 | $action{output} = `$code`; | ||
| 29 | } else { | ||
| 30 | return %action; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | $action{processed} = 1; | ||
| 35 | return %action; | ||
| 36 | } |