Code.RogerHub » perl https://rogerhub.com/~r/code.rogerhub The programming blog at RogerHub Fri, 27 Mar 2015 23:04:04 +0000 en-US hourly 1 http://wordpress.org/?v=4.2.2 Getting a python-like shell for Perl https://rogerhub.com/~r/code.rogerhub/infrastructure/541/getting-a-python-like-shell-for-perl/ https://rogerhub.com/~r/code.rogerhub/infrastructure/541/getting-a-python-like-shell-for-perl/#comments Wed, 26 Mar 2014 22:01:48 +0000 https://rogerhub.com/~r/code.rogerhub/?p=541 When learning a new language, I find it really helpful if I can test out new syntax and language constructs without going through the trouble of creating a file and all the boilerplate along with it. Perl doesn’t have this capability built-in, as far as I know, but there’s this great CPAN module that claims to do the same thing. It’s a short little module (just about 100 SLOC), and it gives you a familiar prompt:

Perl 5.14.2 (Tue Feb  4 23:09:53 UTC 2014) [linux panlong 2.6.42-37-generic #58-ubuntu smp thu jan 24 15:28:10 utc 2013 x86_64 x86_64 x86_64 gnulinux ]
Type "help;", "copyright;", or "license;" for more information.
>>> 

It’s not very obvious how to set up the thing though. I installed the module and its dependencies via cpanm, and then created this little snippet in a file called perlthon.pl:

#!/usr/bin/perl
use 5.010;
use strict;
use warnings;

use Perl::Shell;
Perl::Shell::shell();

Then, the shell started right up.

]]>
https://rogerhub.com/~r/code.rogerhub/infrastructure/541/getting-a-python-like-shell-for-perl/feed/ 1