in reply to Re: Re: Memory allocation strategies
in thread Memory allocation strategies

a nice idiom for preextending strings is
substr($a, length($a), 100, "")
At least I think it works. This came up on p5p when I was arguing that you should be able to do
length($a) = 20;
to truncate a string to 20 chars. Due to a less than clear initial posting, most people thought I was looking for pre-extension and someone said I should just use the above.

Replies are listed 'Best First'.
Re: Re: Re: Re: Memory allocation strategies
by demerphq (Chancellor) on Sep 03, 2003 at 10:41 UTC

    Hmm Im in the process of writing an sub that will do the same thing as length($a)=20. :-) Unfortunatly the B classes dont provide a way to get/set the full set of attributes for a PV.

    And personally I think that length($a)=$x should work both ways, truncating and extending (preferable with extending with "\0"'s )


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...