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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
why not
print "first success\n","second success\n" if $test;
print "first success\n","second success\n" if $test;
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...