in reply to Perl REPLs
My repl is basically the same 15 line perl script I wrote nearly 15 years ago. 3 years ago it looked like this.
Today, it looks like this:
C:\test>type \perl64\bin\p1.pl #! perl -slw use 5.010; no warnings 'portable'; use feature qw[ say state ]; use threads; use threads::shared; #use strict; #use Win32::API::Prototype; use Time::HiRes qw[ time sleep ]; use Benchmark qw[cmpthese]; use Data::Dump qw[ pp ]; ##$Data::Dump::MAX_WIDTH = 200; #use Data::Dumper; use Devel::Size qw[ size total_size]; use List::Util qw[ sum reduce max min maxstr minstr shuffle ]; sub mem{ `tasklist /nh /fi "PID eq $$"` =~ m[(\S+ K)$] } $| = 1; $" = $, = ' ';#" $TOOK = 0; my( $took, $start, $end ) = ( '', 0, 0 ); while( 1 ) { $took = $TOOK ? $end - $start : ''; $_code = ''; printf "[%s]{%s} Perl> ", $! || $@ || $? || 0, $took; $_code .= <STDIN> until $_code =~ m[;;\s*$]; chomp $_code; system 1, 'cmd /k' and next if $_code =~ m[^!!;;\s*$]s; if( $_code =~ m[^!(.+);;\s*$]s ) { my $cmd = $1; $cmd =~ s[(\$\w+)][$1]gee; system "cmd.exe /c $cmd"; $! = ($? << 8); next; } last if $_code =~ m[^(quit|exit|q);;\s*$]; $! = 0; # eval { local $ENV{ PERL_SIGNALS } = 'unsafe'; local $SIG{ INT } = sub{die;}; $start = time; eval $_code; $end = time; # }; }
It has at various times had more preloaded stuff, and less; and more and less logic in the loop, but the core 10 or so lines have barely changed at all.
It has never, and will never be published because then someone would want it to "work properly with lexical variables"; "automatically print the results of every evaluation"; and "support strict"; etc. All Of which I have no need for, nor the desire to complicate my single most used perl script ever, by adding.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl REPLs
by Discipulus (Canon) on Nov 04, 2016 at 09:02 UTC | |
by BrowserUk (Patriarch) on Nov 04, 2016 at 11:18 UTC | |
|
Re^2: Perl REPLs
by RonW (Parson) on Nov 03, 2016 at 19:02 UTC |