Forum Moderators: coopster & phranque

Message Too Old, No Replies

Meaning of $variablename ¦¦= 1;

versus $variablename = 1;

         

SuperstitionA

1:30 am on May 31, 2006 (gmt 0)

10+ Year Member



Hi everyone,

I am working with a Perl script's pm file and I have attempted to turn to Google for my answers. However, I am trying to understand the function of the two vertical pipes that precede the equal sign when assigning some variables either a numeric value:

$C ¦¦ = 1;

or string value:

$C ¦¦ = 'string';

I have worked with Perl but not recently, and need to brush up on these things.

Google does not return anything useful when the search contains ¦¦ = characters, and I do not know what words to enter that describe these.

I have looked at some CGI tutorials but no mention in what I have read about the pipes.

Could someone please provide an explanation or a link?

Thanks in advance.

Larry

KevinADC

3:43 am on May 31, 2006 (gmt 0)

10+ Year Member



the double pipes is the logical 'Or' operator:

[perldoc.perl.org...]

used with the assignment operator '=' it has the same meaning as:

$C = $C ¦¦ 1;

which is the same as:

$C = defined($C)? $C : 1;

which is the same as:

if (defined($C)) {
$C = $C;
}
else {
$C = 1;
}

this page lists all the perl operators and has some explanations of them:

[perldoc.perl.org...]

if you are going to working with perl again you will want to bookmark the site:

[perldoc.perl.org...]

SuperstitionA

1:34 pm on Jun 1, 2006 (gmt 0)

10+ Year Member



Hey, thank you Kevin, for the information, and I will go check those links out.

I really need to check out some literature from the library again, if I can find a way there, but I will devour these sites' offerings in the meantime.

Thanks again!

Larry

KevinADC

5:38 pm on Jun 1, 2006 (gmt 0)

10+ Year Member



You're welcome :)