Link to home
Start Free TrialLog in
Avatar of Peewee
Peewee

asked on

mutiple commands from an if statement on one line...

My question is quite simple suppose i have multiple commands to do, ie

print "success";
$counter++;

can i do these on a line if statement.

ie
print "success" && $counter if (condition is true);

many thanks
Peewee
ASKER CERTIFIED SOLUTION
Avatar of rj2
rj2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pagemastah
pagemastah

you may use the DO-WHILE statement... for example:

do
{
print "success\n";
$counter++;
}
while ($counter < 10);

##### this will print 'success' and increment the value of $counter and then stops if the value of $counter is not less than 10 anymore.

i hope this one helps...

Avatar of Peewee

ASKER

rj2,

here's what i used:
#!/usr/bin/perl

print "start\n";
$test=1;
print "first success\n"), (print "second success\n") if $test;
print "end\n";


many thanks
Peewee
Avatar of ozo
why not

print "first success\n","second success\n" if $test;