Re: understanding the ||= operator

2011-02-13 Thread Peter Scott
On Sat, 12 Feb 2011 12:13:13 +0100, Dr.Ruud wrote: > On 2011-02-11 11:26, Alan Haggai Alavi wrote: > >> $variable_1 ||= $variable_2 is equivalent to $variable_1 = $variable_1 >> || $variable_2. > > Hmm, I don't buy that, I would say that $x ||= $y is equivalent to > >$x = $y unless $x; > >

Re: understanding the ||= operator

2011-02-12 Thread Dr.Ruud
On 2011-02-11 11:26, Alan Haggai Alavi wrote: $variable_1 ||= $variable_2 is equivalent to $variable_1 = $variable_1 || $variable_2. Hmm, I don't buy that, I would say that $x ||= $y is equivalent to $x = $y unless $x; alternatively: $x or $x = $y; because the setting of $x only needs

Re: understanding the ||= operator

2011-02-12 Thread Alan Haggai Alavi
Hi, > then that I don't understand is the program logic :-( It is a logical OR. Quoting `perldoc perlop`: C-style Logical Or Binary "||" performs a short-circuit logical OR operation. That is, if the left operand is true, the right operand is not even evaluated. Scalar

Re: understanding the ||= operator

2011-02-12 Thread Alan Haggai Alavi
Hi, > 12$sheet -> {MaxRow} ||= $sheet -> {MinRow}; Line 12 can be written as: $sheet->{'MaxRow'} = $sheet->{'MaxRow'} || $sheet->{'MinRow'}; For example: $variable_1 ||= $variable_2 is equivalent to $variable_1 = $variable_1 || $variable_2. The same applies to: **=+=

Re: OT: understanding the ||= operator

2011-02-11 Thread Uri Guttman
> "sw" == shawn wilson writes: RD> Perl has no proper boolean values. Instead, the boolean operators RD> treat zero, undef, and the null string '' all as false. Anything else RD> is true. sw> to be pedantic, '0' is also false. it isn't exactly the same as 0. sw> come again with t

OT: understanding the ||= operator

2011-02-11 Thread shawn wilson
RD> Perl has no proper boolean values. Instead, the boolean operators RD> treat zero, undef, and the null string '' all as false. Anything else RD> is true. to be pedantic, '0' is also false. it isn't exactly the same as 0. come again with that? how is: $string = 0; #different from $string =

Re: understanding the ||= operator

2011-02-11 Thread Uri Guttman
> "RD" == Rob Dixon writes: RD> On 11/02/2011 10:38, mailing lists wrote: 12$sheet -> {MaxRow} ||= $sheet -> {MinRow}; >>> >>> Line 12 can be written as: >>> $sheet->{'MaxRow'} = $sheet->{'MaxRow'} || $sheet->{'MinRow'}; >> >> >> then that I don't understand

Re: understanding the ||= operator

2011-02-11 Thread Rob Dixon
On 11/02/2011 10:38, mailing lists 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?? Perl has

Re: understanding the ||= operator

2011-02-11 Thread Jay Savage
On Fri, Feb 11, 2011 at 5:38 AM, mailing lists 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 line

Re: understanding the ||= operator

2011-02-11 Thread Brian Fraser
It's the If $sheet->{MaxRow} is false[0], then the value of $sheet->{MinRow} is assigned to that variable; If it's true, nothing happens. Same deal with line 14; you canr ead more about the logical-or and other operators in perldoc perlop[1]. Brian. [0] http://perldoc.perl.org/perlsyn.html#Truth

Re: understanding the ||= operator

2011-02-11 Thread mailing lists
>> 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?? -- To unsubscribe, e-mail: beginners-unsubscr.

understanding the ||= operator

2011-02-11 Thread mailing lists
Hello, for the following program, what is the function of lines 12 and 14 ??? 1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 use 5.010; 6 use Spreadsheet::XLSX; 7 8 my $excel = Spreadsheet::XLSX -> new ('Datos RCP 4_2_11-v2.xlsx'); 9 10 foreach my $sheet (@{$excel -> {W