Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Understanding Chaos

by shmem (Chancellor)
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/

sub { print __PACKAGE__ }

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

my ($class,$file,$h,$load,$package); $class = ''; $file = './auto/AutoReloader/'; $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/', 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.


_($_=" "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}

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2023-12-11 03:44 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (41 votes). Check out past polls.