On Fri, Sep 07, 2001 at 02:32:51PM -0600, Chris Fedde wrote:
> Find below recent patches to the FAQ derived from postings to usenet CLPM.
> Is there a better place I should be posting these?
I'll bounce [EMAIL PROTECTED] a copy.
Very nice work, BTW! I'll now procede to pick it to pieces. ;)
> +=item * Consider using C<eval>
> +
> +If you need to initialize a large variable in your code, you
> +might consider doing it with an C<eval> statement:
> +
> + my $large_string = eval ' "a" x 5_000_000 ';
> +
> +This allows perl to immediately free the memory allocated to the
> +eval statement, but carries a (small) performance penalty.
Does this really work?
> +=item * Clean out the trash
> +
> +If you have a variable which consumes a large amount of RAM, you may
> +want to explicitly undef() once it's no longer needed. Perl might then
> +return the additional memory back to the OS.
Might want to clarify that it's:
undef $foo;
not
$foo = undef;
And I think that 'Perl might then return the additional memory back to
the OS' is a little white lie. Currently, Perl never returns memory
back to the OS AFAIK. It just returns it back to it's own free memory
pool. But FAQ readers don't need to know that. :P
Am I right?
> @@ -747,6 +753,7 @@
> last names `Knuth' and `Kant' are both mapped to the soundex code K530.
> If Text::Soundex does not do what you are looking for, you might want
> to consider the String::Approx module available at CPAN.
> +And some english speakers might find Text::Metaphone useful too.
There's also Text::DoubleMetaphone which tries to be even more
accurate. Of course, it STILL gets Schwern wrong. ;)
> +If you want not only to expand simple variables but want the full
> +power of Perl's double-qouted interpolation then:
> +
> + # Assume $text does not contain "\n__EOD__\n"
> + chop( $text = eval "<<__EOD__\n$text\n__EOD__" );
> + die if $@;
> +
> +This allows $text to contain arbintrary Perl code (for example
> +$text = "@{[ system 'rm -rf /' ]}") so before you use this method
> +you must be absolutely sure that $text can only come from sources
> +who you would trust to have a shell accounts on your box.
Point them at taint mode.
> See also ``How do I expand function calls in a string?'' in this section
> of the FAQ.
>
> @@ -941,6 +960,23 @@
> The C<use warnings> pragma and the B<-w> flag will warn you about these
> matters.
>
> +In Perl 6, a scalar always has a leading $, an array always has a
> +leading @ (even when accessing its elements or slicing it), and a
> +hash always has a leading % (even when accessing its entries or
> +slicing it).
Should we really be talking about Perl 6 in a Perl 5 FAQ? Seems to
confuse the issue.
> -Otherwise you'll have to write your own multiplexing print
> -function--or your own tee program--or use Tom Christiansen's,
> -at http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz , which is
> -written in Perl and offers much greater functionality
> -than the stock version.
> +You might also find the script at
> +http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz interesting.
A better place to point people would be the Perl Power Tools
distribution, which has a tee, either Bundle::PPT on CPAN or
http://language.perl.org/ppt/.
Otherwise, a wonderful update!
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
I have this god-awful need to aquire useless crap!!!