Differences
This shows you the differences between two versions of the page.
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 ' | ||
+ | no strict ' | ||
+ | use warnings; | ||
+ | |||
+ | use Data:: | ||
+ | $Data:: | ||
+ | |||
+ | $| = 1; | ||
+ | |||
+ | # an alias for exit() | ||
+ | sub quit { exit; } | ||
+ | |||
+ | my ($ver, | ||
+ | $maj += 0; | ||
+ | $min += 0; | ||
+ | print +(split '/', | ||
+ | |||
+ | $, = ','; | ||
+ | $THE_PROMPT = '% '; | ||
+ | print $THE_PROMPT; | ||
+ | while (<>) { print eval; print +($@ || " | ||
+ | </ | ||
+ | |||
+ | usage: | ||
+ | < | ||
+ | $ alias perlsh=' | ||
+ | $ perlsh | ||
+ | perl.exe 5.10.0 | ||
+ | % @l=qw(the quick brown fox jumps over the lazy dog) | ||
+ | the, | ||
+ | % @sorted_by_length = map {$_-> | ||
+ | the, | ||
+ | </ | ||
+ | |||
+ | |||
===== Optimizing Perl ===== | ===== Optimizing Perl ===== | ||