Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
perl [2008/09/26 20:34]
a
perl [2009/05/25 00:35] (current)
Line 1: Line 1:
 +===== An interactive perl shell =====
 +<code perl|f perlsh.pl>
 +#!perl
 +
 +use strict;
 +no strict 'vars';
 +no strict 'refs';
 +use warnings;
 +
 +use Data::Dumper;
 +$Data::Dumper::Indent--;
 +
 +$| = 1;
 +
 +# an alias for exit()
 +sub quit { exit; }
 +
 +my ($ver,$maj,$min) = ($] =~ /(\d+)\.(\d{3})(\d{3})/);
 +$maj += 0;
 +$min += 0;
 +print +(split '/', $^X)[-1], " $ver.$maj.$min\n";
 +
 +$, = ',';
 +$THE_PROMPT = '% ';
 +print $THE_PROMPT;
 +while (<>) { print eval; print +($@ || "\n") . $THE_PROMPT };
 +</code>
 +
 +usage:
 +<code>
 +$ alias perlsh='perl ~/bin/perlsh.pl'
 +$ perlsh
 +perl.exe 5.10.0
 +% @l=qw(the quick brown fox jumps over the lazy dog)
 +the,quick,brown,fox,jumps,over,the,lazy,dog
 +% @sorted_by_length = map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {[$_, length]} @l
 +the,fox,the,dog,over,lazy,quick,brown,jumps
 +</code>
 +
 +
 ===== Optimizing Perl ===== ===== Optimizing Perl =====
  
perl.1222454054.txt.gz ยท Last modified: 2009/05/25 00:34 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready