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

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



on 11/22/2000 12:43 PM, Ronald J Kimball at rjk@linguist.dartmouth.edu
wrote:

> 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

nice guess, but no. observe the loop:

foreach my $sort_by (reverse sort keys %{$master_maps_list{$GameType}}) {
    my( $file_location, $Title, $size, $review, $rating ) =
@{$master_maps_list{ $GameType }{ $sort_by }};
    if (param()) {
        next if ((param('short') eq 'rated'  ) && ($rating == -1));
        next if ((param('short') eq 'unrated') && ($rating != -1));
    };
    print qq{<tr><td align="left" valign="top"><font size="2">};
    print qq{<a href="} . $download_url . $GameType . '/' . $file_location .
qq{" target="_new">$Title</a></font></td>\n};
    print qq{<td align="right" valign="top"><font size="2">};
    print size_calc($size) . qq{</font></td>\n};
    print qq{<td align="center" valign="top" bgcolor="} .
$rating{'color'}->[ &coerce($rating) ] . qq{"><font size="2">};
    if ($rating != -1) {
        print qq{<a href="http://www.planetunreal.com} . $review . qq{"
target="_new">};
        print qq{<font color="black"><b>$rating</b></font></a><br>\n};
    } else {
        print qq{N/A<br>\n};
    }
    print qq{</font></td></tr>\n};
};  # foreach $sort_by



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