in reply to Re: My scalars swell
in thread My scalars swell

I'd like to alter your test just a little bit to prove a point. Trying to code to the implementation of a language just isn't wise. Observe:
my @foo = (0..100000); my @t; foreach my $f (@foo) { # comment/uncomment the next lines to change behaviors $f.=""; push(@t, $f+0); } system("ps auxwwww | grep perl"); sleep(10); exit(0);
The problem is that the memory saved by trying coerce the scalar back to a number to save memory doesn't always work. For example, if the scalar has been used in a string before you don't get the memory back: In this case (I believe) that perl remembers having done an number->string conversion and caches the value to prevent having to do it again (or have I got that backwards..?). At any rate, trying to outsmart the interpreter doesn't always work and starts awful cargo-cult beliefs.

Replies are listed 'Best First'.
Re: Re: Re: My scalars swell
by jackdied (Monk) on Oct 21, 2001 at 01:11 UTC
    I agree it is bordering on black magic, but I've used it to good effect to squeeze the last ounces of mem from my computer. Does anyone else do the Dr Dobbs puzzle every month?

    I tried doing a super search and a google search, but found nothing. Is there a pragma or hint that you can pass to perl to tell it you are just using really plain integer scalars?