X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlfaq3.pod;h=4085684ef7a4747b5d7300a359755470ecbf1e89;hb=bc06af7496abc68809dea149d963eea3f2e007f9;hp=efa764df60c491a1ba0bd5ce9682a35beb837eab;hpb=6eca140854a73c1ec4270b4256675f7be02d7709;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlfaq3.pod b/pod/perlfaq3.pod index efa764d..4085684 100644 --- a/pod/perlfaq3.pod +++ b/pod/perlfaq3.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq3 - Programming Tools ($Revision: 1.4 $, $Date: 2001/10/02 19:42:02 $) +perlfaq3 - Programming Tools ($Revision: 1.6 $, $Date: 2001/10/03 23:06:15 $) =head1 DESCRIPTION @@ -164,9 +164,13 @@ related to generating nicely printed output of documents. =head2 Is there a ctags for Perl? -There's a simple one at +Recent versions of ctags do much more than older versions did. +EXUBERANT CTAGS is available from http://ctags.sourceforge.net/ +and does a good job of making tags files for perl code. + +There is also a simple one at http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz which may do -the trick. And if not, it's easy to hack into what you want. +the trick. It can be easy to hack this into what you want. =head2 Is there an IDE or Windows Perl Editor? @@ -519,6 +523,51 @@ When the files you're processing are small, it doesn't much matter which way you do it, but it makes a huge difference when they start getting larger. +=item * Use map and grep selectively + +Remember that both map and grep expect a LIST argument, so doing this: + + @wanted = grep {/pattern/} ; + +will cause the entire file to be slurped. For large files, it's better +to loop: + + while () { + push(@wanted, $_) if /pattern/; + } + +=item * Avoid unnecessary quotes and stringification + +Don't quote large strings unless absolutely necessary: + + my $copy = "$large_string"; + +makes 2 copies of $large_string (one for $copy and another for the +quotes), whereas + + my $copy = $large_string; + +only makes one copy. + +Ditto for stringifying large arrays: + + { + local $, = "\n"; + print @big_array; + } + +is much more memory-efficient than either + + print join "\n", @big_array; + +or + + { + local $" = "\n"; + print "@big_array"; + } + + =item * Pass by reference Pass arrays and hashes by reference, not by value. For one thing, it's