(Hope this is the right spot for this!)
Pythonists complain that Perl doesn't have an interactive mode, but of course you can easily make one. However other examples I have seen were 20 line scripts, a little while ago I made up this one liner (which I tend to stash in a minimal shell script called ip, on every machine I use):
(Of course half that is just for prettification, if you don't mind ugly you can just say perl -ne 'print eval'.) It does pretty much everything you hope (provided your shell handles up arrow history for you). An example session:perl -ne 'print join(",", eval),"\n> "'
Although also very useful for testing small confusions about syntax, I've found it so handy as a sort of super calculator that I now keep an instance running all the time../ip $a=2 2 > $a**10 1024 > $a *= 3 6 > sprintf '%lx', ~$a fffffff9 > use Digest::SHA 'sha256_hex' > sha256_hex 10 4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5 > exit
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Interactive perl
by itub (Priest) on Mar 23, 2005 at 15:01 UTC | |
by ysth (Canon) on Mar 23, 2005 at 16:13 UTC | |
by tlm (Prior) on Mar 23, 2005 at 16:28 UTC | |
by ysth (Canon) on Mar 23, 2005 at 18:17 UTC | |
Re: Interactive perl
by chas (Priest) on Mar 24, 2005 at 03:51 UTC | |
by banjo (Initiate) on Aug 19, 2006 at 12:28 UTC | |
Re: Interactive perl
by hossman (Prior) on Mar 23, 2005 at 23:41 UTC | |
Re: Interactive perl
by blazar (Canon) on Mar 25, 2005 at 13:24 UTC |
Back to
Cool Uses for Perl