Slides for the talk the-end at yapc-na-2012
-
The __END__
of everything
-
freenode
#perl
-
"But I can't
use CPAN"
-
ARGH
-
Hate that
so much!
-
Urge to
__END__
them rising!
-
WHYYYYY
-
"I'm not
root"
-
Ok, well, here's
how you make
CPAN DTRT
-
... 20
minutes
later
-
ARGH
-
So I wrote
local::lib
-
So far
so good
-
"I need to
deploy a
single file"
-
ARGH
-
Ok, well, let's
try and make
PAR DTRT
-
... 20
minutes
later
-
ARGH
-
So I wrote
App::FatPacker
-
(and then
miyagawa++
used both in
cpanminus :)
-
So far
so good
-
-
"This script
needs to run
once on 200
machines."
-
"Fatpacking
is way too
much effort."
-
...
-
Fair ...
point ...
-
GODS
DAMNIT
-
Ok, well
-
*scrabbles
for plan B*
-
Hmm
-
__DATA__
-
__END__
-
Perl stops
parsing
-
Hmmmmmmm
-
perl -
-
STDIN
stays
open
-
Hmmmmmmm!
-
So ...
fatpacked
bootstrap
-
open2(
$stdin, $stdout,
'ssh', $host,
'perl', '-'
);
-
print $stdin $fatpacked;
print $stdin "__END__\n";
-
What about
communications?
-
Lines of
JSON on
the wire
-
JSON->new
->filter_json_single_key_object(
__remote_object__ => sub {
$self->_id_to_remote_object(@_);
}
)
-
Proxy object
with AUTOLOAD
-
$self->{remote}->call(
$method => @_
);
-
Ohshi-
-
What about
modules I
didn't fatpack?
-
Hmm.
-
Wait.
-
Fatpacker
uses a
coderef
in @INC
-
Hmmmmmm.
-
Well there's no
reason I have to
use just ONE ...
-
... or even
an object!
-
sub ModuleLoader::Hook::INC {
my ($self, $module) = @_;
my $code = $self->sender
->source_for($module);
open my $fh, '<', \$code;
return $fh;
}
-
$self->sender ?
-
That
bit's
easy!
-
$conn->new_remote(
class => 'ModuleSender'
);
-
... which gets
it from the
source host
-
first { -f $_ }
map catfile($_, $pm_file),
grep !/$Config{archname}$/,
@INC;
-
And to add a
little sugar ...
-
sub new::on {
my ($class, $on, $args) = @_;
__PACKAGE->connect($on)
->new_remote(
class => $class,
args => \@args
);
}
-
Ok, great.
-
... OOOOH
-
Eval::WithLexicals
-
PURE PERL
EVAL CAGE
-
my $eval = Eval::WithLexicals->new::on(
'user@host',
#
);
-
my $eval = Eval::WithLexicals->new::on(
'user@host', # sshes in and starts up
#
);
-
my $eval = Eval::WithLexicals->new::on(
'user@host', # sshes in and starts up
# or just 'host' or 'user@' to sudo
);
-
$eval->eval($code);
-
$eval->eval('my $x = 1;'); # 1
$eval->eval('++$x'); # 2
-
My::Shiny::Class->new::on(
$conn, { ... }
);
-
$conn->get_remote_sub(
'Sys::Hostname::hostname'
)->();
-
Think you
STILL can't
use CPAN?
-
I SAY YOU
CAN, YOU CAN
USE CPAN,
TIM I AM
-
Object::Remote
will ship
next week
-
Just please
let's not
mention win32!
-
... or
microperl on
Nintendo DS
-
Thank You
IRC:mst
mst@shadowcat.co.uk
@shadowcat_mst