On Fri, Feb 11, 2011 at 5:38 AM, mailing lists <listas.cor...@yahoo.es> wrote: >>> 12 $sheet -> {MaxRow} ||= $sheet -> {MinRow}; >> >>Line 12 can be written as: >>$sheet->{'MaxRow'} = $sheet->{'MaxRow'} || $sheet->{'MinRow'}; > > > then that I don't understand is the program logic :-( > > what's the purpose of lines 12 and 14??
$sheet->{'MaxRow'} and $sheet->{'MinRow'} are used in the range in line 13. Line 13 goes through a loop for every $row from MinRow to MaxRow. If MaxRow isn't defined, the range operator in line 13 will warn about uninitialized values. And if MaxRow isn't true Spreadsheet::XLSX will probably complain since there is no row 0 in Excel. So line 12 checks to make sure that MaxRow is true. If MaxRow is true, the ||= operator does nothing, but if MaxRow is false, the ||= operator assigns the value of MinRow to it. This ensures that MaxRow is always true (unless MinRow is also undef, which would be a bigger problem) and that line 13 functions as expected. If MinRow == MaxRow (i.e. there is only one row), the loop only executes once. HTH, -- j -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/