RE: perl - a small reminder

  • From: "Sina Bahram" <sbahram@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 5 Nov 2008 14:09:19 -0500

You're confusing brackets, braces, and parentheses.

Parentheses are like this

if($a > 5)

Brackets are used for arrays, like this:

$myArray[4] = "hello";

Braces are like this:

If($a > 5)
{
# this line is in a pair of braces
}

Take care,
Sina

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Lamar Upshaw
Sent: Wednesday, November 05, 2008 2:02 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: perl - a small reminder

Thanks for this, but when doing the one liner, don't we still have to use 
the brackets? Your example was like this:
$b = 1 if $a >0;

But do we have to do it like this?
$b = 1 if ($a >0);

With All Respect,
Upshaw, Lamar T
----- Original Message ----- 
From: "Humberto Rodriguez" <sub@xxxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, November 05, 2008 10:48 AM
Subject: RE: perl - a small reminder


> Hello Lamar:
>
> As I understand it, PHP works as you say, but in Perl, to do it, you 
> reverse
> the order in the one--liner:
>
> $b = 1 if $a >0;
>
> HTH,
>
> Humberto
>
> -----Original Message-----
> From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Lamar Upshaw
> Sent: Wednesday, November 05, 2008 1:40 PM
> To: programmingblind@xxxxxxxxxxxxx
> Subject: perl - a small reminder
>
> I need a little reminder and clarity about "If Else" statements.
> I only need to use the braces when there's more than one statement made
> based on the condition of the "if" statement, right?
>
> if ($a > 0)
> {
> $b =1;
> $c =2;
> }
>
> But, if only one statement is made, I don't need the braces?
> if ($a >0)
> $b = 1;
>
> With All Respect,
> Upshaw, Lamar T
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
> 

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: