-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathperl-live.pl
25 lines (22 loc) · 947 Bytes
/
perl-live.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use utf8; use strict; use warnings;
# uncomment if need by default
# use feature qw'say state';
# use experimental qw'smartmatch switch lexical_subs declared_refs defer';
use Encode 'decode_utf8';
use Getopt::Std 'getopts';
use PadWalker 'peek_my'; use Package::Stash ();
use AnyEvent;
no strict 'vars'; use vars map '$z::'.$_, qw(st in hint buf ctx w); use strict 'vars';
($z::st, $z::in)= (Package::Stash->new('main'), {});
getopts( g => $z::in );
$z::w = AE::io *STDIN, 0, sub {
if (eof()) {
STDIN->clearerr;
eval 'BEGIN { ($^H,${^WARNING_BITS},%^H) = @{$z::hint} if $z::hint }'
.decode_utf8(substr($z::buf//='', 0, length $z::buf, ''))
.'; package main; $z::ctx = peek_my(0);'
.'BEGIN { $z::hint = [$^H,${^WARNING_BITS},%^H] }';
map $z::st->add_symbol($_, $z::ctx->{$_}), keys%$z::ctx if $z::in->{g};
warn if $@ }
else { $z::buf .= scalar <> } };
AE::cv->recv;