[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] shift; vs my $temp = shift;



on 11/22/2000 05:38 AM, Bart Lateur at bart.lateur@skynet.be wrote:

> On Wed, 22 Nov 2000 04:42:46 -0500, Scott R. Godin wrote:
> 
>> I had to change 
>> sub size_calc {
>> shift;
>> ($_ <= 1024) ? return $_ . "k" : return sprintf('%.2f', ($_/1024)) .
>> "MB"; 
>> }
>> 
>> to
>> 
>> sub size_calc {
>> my $mapsize = shift;
>> ($mapsize <= 1024) ? return $mapsize . "k" : return sprintf('%.2f',
>> ($mapsize/1024)) . "MB";
>> }
>> 
>> and I have no idea why. Any ideas?
> 
> You have no idea why? Doing.
> 
> shift() gets an item and you throw it away. shift() does NOT store it
> into $_, as you seem to assume. $_ is still what it was when you called
> this sub.
> 
> This would work, too:
> 
> sub size_calc {
> local $_ = shift;
> ... #same as rest of v1.
> }
> 
> 

*incredulous head-scratching*

Bart, the oddest thing is that it WAS working.. for at least two weeks(!)..
and suddenly stopped as I've made further changes to the code.

I don't remember what I changed, but obviously that's besides the point now.

Thanks for the wake-up-call. Thought I was losing my mind. =:\


-- 
Scott R. Godin            | e-mail : mactech@webdragon.net
Laughing Dragon Services  |    web : http://www.webdragon.net/



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org