Re: perl - a small reminder

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 5 Nov 2008 21:17:05 +0200

Not exactly. You need to use braces everytime.

But you could use something like this if you have a single statement:

print "ok" if $var == 1;

instead of
if ($var == 1) {
print "ok";
}

Octavian

----- Original Message ----- From: "Lamar Upshaw" <lupshaw@xxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, November 05, 2008 8:40 PM
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

Other related posts: