Jarkko Hietaniemi wrote:
> On Sun, Sep 09, 2001 at 01:29:51AM +0200, Abigail wrote:
>
>> On Fri, Sep 07, 2001 at 10:49:00PM -0600, Chris Fedde wrote:
>>
>>> On Fri, 7 Sep 2001 16:58:32 -0400 Michael G Schwern wrote:
>>> +------------------
>>> | 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?
>>> |
>>> | > +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?
>>> +------------------
>>>
>>> Apparently.
>>
>> I am not at all happy with this. This problem of using too much memory
>> should be fixed at the language level - and not at the program level.
>> Such practices should certainly not be recommended in a FAQ.
>
>
> I agree.
>
I'm not sure of this but it seems to me that the expression will work
without the eval. I'm guessing the eval is there as form of exception
handling in case the allocation fails. If this is the case then the
eval is being used for a well documented and recommended technique.
Rev