usenet@carssdf.UUCP (John Watson) (03/01/91)
Most of my scripts look something like this:
while (<>) { chop; @F=split(/_/);
.... some code for each line ....
}
This gobbles up memory. If I add a "reset 'F';" line in the loop, it is
fine. Should I need to do this? If necessary, why wouldn't a line of
"undef @F;" work? (it doesn't).
John Watson ... Independent Programmer
tchrist@convex.COM (Tom Christiansen) (03/01/91)
From the keyboard of usenet@carssdf.UUCP (John Watson): :Most of my scripts look something like this: : :while (<>) { chop; @F=split(/_/); : .... some code for each line .... :} : :This gobbles up memory. If I add a "reset 'F';" line in the loop, it is :fine. Should I need to do this? If necessary, why wouldn't a line of :"undef @F;" work? (it doesn't). Yes, undef should work fine. What patchlevel of perl are you at and on what hardware/software platform? Actually, you shouldn't even need that, since each successive assignment to @F should in theory free of the memory associated with the previous values. A couple of miscellaneous asides... Don't you mean: @F = split(' '); (Unless you really have underbars as field separators.) Also, you say that most of your scripts to the split(). They'll run a little faster if you only split when you need to. --tom -- "UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things." -- Doug Gwyn Tom Christiansen tchrist@convex.com convex!tchrist