in reply to Re: The safety of string eval and block eval.
in thread The safety of string eval and block eval.
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; sub create_iter { my ($code_ref, @rest) = @_; sub { $code_ref->(@rest) } } my $iter = create_iter(sub { $_[0] += 2 }, 0); say $iter->() for 1 .. 5; my $fibo = create_iter(sub { @_[0, 1] = ($_[1], $_[0] + $_[1]); $_[1] +}, 1, 1); say $fibo->() for 1 .. 7; my $fact = create_iter(sub { $_[1] *= ++$_[0] }, 1, 1); say $fact->() for 1 .. 5;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: The safety of string eval and block eval.
by Laurent_R (Canon) on Aug 15, 2016 at 11:13 UTC | |
by afoken (Chancellor) on Aug 15, 2016 at 19:51 UTC | |
by haukex (Archbishop) on Aug 16, 2016 at 07:45 UTC |