And a small example that uses it:package LazyFilt; use 5.8.0; use warnings; use strict; use Data::Lazy; use Filter::Util::Call; our $state = 0; sub import { filter_add([]); } sub filter { my $status = filter_read(); return $status unless $status > 0; my $result = ""; my @stmts = split /;/; foreach my $stmt (@stmts) { my @lazyass = split /=\[l\]/,$stmt; if (@lazyass == 1) { $result .= $stmt . ";"; next } die "We don't support this (@lazyass)!" if (@lazyass > 2); $result .= "tie $lazyass[0], 'Data::Lazy', sub { $lazyass[1] };"; } $result .= "\n"; $_ = $result; return $status; } 1;
If anyone actually fancies this I could even clean it up properly.use LazyFilt; use strict; use warnings; sub calc { my ($p1,$p2,$p3) = @_; print "Here is where really slow stuff happens\n"; my $sum = $p1 + $p2; } my $result =[l] calc(30,20,"FooBar"); my $result2 =[l] calc($result,20,"YoYo"); print "Just about now I need to show the first result: $result\n"; my $result3 = $result + $result2; print "And now I need the whole result: $result3 \n"; print "After this it is free to poke around: $result2\n"; my $a = 10; my $result4 =[l] 2+$a; $a = 14; print "Result? $result4\n";
In reply to Re: Re: Re: What could I do with just Perl?
by dref
in thread What could I do with just Perl?
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |