LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-02-2009, 12:45 PM   #1
energiza
Member
 
Registered: Oct 2004
Location: Queretaro Mexico
Distribution: SUSE 10.2
Posts: 51

Rep: Reputation: 15
New Operator ?¿


Hello, I've been googling about this operator "||=", without success. Maybe I'm not reading it properly. I found it in perl module Spreadsheet::ParseExcel, in the samples folder, filename parse.pl. This is the fragment (lines marked in red contain this operator):
Quote:
#!/usr/bin/perl
use strict;
use warnings;

use Spreadsheet::ParseExcel;
use Getopt::Long qw(GetOptions);

my $file;
my $help;
my $dump;

my ($row, $col);

GetOptions(
"file=s" => \$file,
"help" => \$help,

"dump" => \$dump,
"row=i" => \$row,
"col=i" => \$col,
) or usage();
usage() if $help;
usage() if not $file;

my $excel = Spreadsheet::ParseExcel::Workbook->Parse($file);
if ($dump) {
foreach my $sheet (@{$excel->{Worksheet}}) {
printf("Sheet: %s\n", $sheet->{Name});
$sheet->{MaxRow} ||= $sheet->{MinRow};
foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) {
$sheet->{MaxCol} ||= $sheet->{MinCol};
foreach my $col ($sheet->{MinCol} .. $sheet->{MaxCol}) {
my $cell = $sheet->{Cells}[$row][$col];
if ($cell) {
printf("( %s , %s ) => %s\n", $row, $col, $cell->{Val});
}
}
}
}
}
So far I've checked the values of variables before and after the operation, but I see no change.

Hope you can help me to understand its meaning.

Greetings.
 
Old 04-02-2009, 12:49 PM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
||= is logical-OR assignment. [$x ||= $y] is the same as [$x = $x || $y]; when $x is already true it is unchanged and when $x is false, it is assigned the value of $y.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the operator * ./. . . * royeo Linux - Newbie 2 09-03-2006 06:13 PM
the pipe operator AmphetaminePhreak Linux - Newbie 4 07-28-2006 08:39 PM
C++ operator += uman Programming 1 02-20-2005 04:37 PM
c++ [] operator overloading exodist Programming 12 04-17-2004 03:06 PM
~ operator linuxanswer Programming 7 04-08-2004 04:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration