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

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



On Wed, Nov 22, 2000 at 11:39:47AM -0500, Scott R. Godin wrote:
> 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?

> *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.

You changed this:

  size_calc($_);

to something like this:

  size_calc($var);

size_calc() was picking up the value of $_ from the caller.  When you
switched from using $_ in the caller to using some other variable,
size_calc() was still picking up the value of $_.

Ronald

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