Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
perl [2008/09/26 20:28] a created |
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 ===== | ||
| + | |||
| + | First run the script with profiling enabled: | ||
| + | |||
| + | perl -d:DProf myscript.pl | ||
| + | |||
| + | then run the profile-dumper: | ||
| + | |||
| + | | ||
| + | |||
| + | ===== Copy (duplicate) a two-dimensional array in Perl ===== | ||
| + | |||
| + | | ||
| + | |||
| ===== CPAN modules fail to compile ===== | ===== CPAN modules fail to compile ===== | ||

