John Weiss wrote:

Wow! Long time, no hear! Good to have you back.

>> Can someone explain this piece of perl to me in English
>>         $i++ while ${$row->{"cells"}} [$i]->{"multicolumn"} eq "part";
> John Levon explained it fairly well, but I'd like to add a few
> remarks.
> 1. The Perl expression "++$i while(...some conditional...);" may
>    look equivalent to "while(...some conditional...) { ++$i' }".
> 
>    It may not be.  Beware changing that expression.

Thanks for the info. I didn't ;-)

> 2. I'd write the same expression as:
> 
>       ++$i while (${$row->{"cells"}}[$i]->{"multicolumn"} eq "part");
> 
>    The (..) may not be required on Perl while-expressions, but they
>    make them easier to read.

Indeed they do. I ended up writing it as
        # $rcells holds a reference to the array of cells
        my $rcells = \@{$row->{"cells"}};
        # Paranoia check that we're not attempting to access beyond the
        # end of the array in case reLyX failed to parse the number of
        # columns correctly.
        $i++ while ($i < @{$rcells} &&
                    ${$rcells}[$i]->{"multicolumn"} eq "part");

Since then, I see Amir uses a function ref(...). Is this equivalent to 
\@{...} ?

-- 
Angus

Reply via email to