Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Understanding Chaos

by shmem (Canon)
on Apr 22, 2007 at 20:45 UTC ( #611406=note: print w/ replies, xml ) Need Help??


in reply to Understanding Chaos

What are the suggested power tools?

An extremely helpful powertool is Data::Dump::Streamer, since it not only outputs data structures or code, but nearly all bits necessary for an object to exist.

From my workbench, AutoReloader version 0.03:

#!/usr/bin/perl -w use strict; use Data::Dump::Streamer; use AutoReloader qw(AUTOLOAD); AutoReloader->check(1); $sub = AutoReloader->gensub("foo"); print $sub; $sub->(); print Dump($sub); __END__ AutoReloader=CODE(0x8337994) AutoReloader

with a file auto/AutoReloader/foo.al

sub { print __PACKAGE__ }

Data::Dump::Streamer produces via Dump($sub)

my ($class,$file,$h,$load,$package); $class = ''; $file = './auto/AutoReloader/foo.al'; $h = { check => \do { my $v = undef }, checkref => \do { my $v = 1177271972 }, checksub => \sub { package AutoReloader; use warnings; use strict 'refs'; (stat $_[0])[9]; }, file => './auto/AutoReloader/foo.al', function => 'AutoReloader::foo', inner => \sub { package AutoReloader; print 'AutoReloader'; }, outer => 'V: $AutoReloader1' }; $load = sub { package AutoReloader; use warnings; use strict 'refs'; my($class, $package, $file, $h) = @_; delete $INC{$file}; my $ref = eval "package $package; require '${file}'"; return undef if $@; { unless (&Scalar::Util::reftype($ref) and &Scalar::Util::re +ftype($ref) eq 'CODE') { $ref = \&{$$h{'function'};}; BEGIN {${^WARNING_BITS} = "TUUU\025UUUUUUU\001"} no strict 'refs'; *{$$h{'function'};} = $$h{'outer'} if $$h{'outer'}; } ${$$h{'inner'};} = $ref; my $sub = sub { BEGIN {${^WARNING_BITS} = "TUUUUUUUUUQU\001"} my $cr = $$h{'checkref'}; my $check; $check = ${$$h{'check'};} if defined ${$$h{'check'};}; if (not defined $check) { $check = $AL{'check'}{$class} if defined $AL{'check'}{ +$class}; } if ($check and ${$$h{'checksub'};} and (my $c = &${$$h{' +checksub'};}($file)) != $$cr) { warn "reloading $file" if $Debug; $$cr = $c; &$load($class, $package, $file, $h); } goto ${$$h{'inner'};}; } ; } }; $package = 'AutoReloader'; $AutoReloader1 = bless( sub { package AutoReloader; BEGIN {${^WARNING_BITS} = "TUUUUUUUUUQU\001"} use strict 'refs'; my $cr = $$h{'checkref'}; my $check; $check = ${$$h{'check'};} if defined ${$$h{'check'} +;}; if (not defined $check) { $check = $AL{'check'}{$class} if defined $AL{'che +ck'}{$class}; } if ($check and ${$$h{'checksub'};} and (my $c = &${ +$$h{'checksub'};}($file)) != $$cr) { warn "reloading $file" if $Debug; $$cr = $c; &$load($class, $package, $file, $h); } goto ${$$h{'inner'};}; }, 'AutoReloader' ); $h->{outer} = $AutoReloader1;

Amazing. It is nearly the entire wheel.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}


Comment on Re: Understanding Chaos
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://611406]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-07-24 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (158 votes), past polls