Jensen Kenneth B Sra Afpc/Dpdmpq wrote:

> Can else statements be added?
> 
> print (hi), $somevar++ if( condition ) else print (bye);

good idea but it doens't work that way. try:

#!/usr/bin/perl -w
use strict;

my $var = 1;
$var ? (   print("hello world\n"),
           $var++,
           print("hi world\n"),
           print "\$var is now $var\n"
       ) : print "No!!!\n";

__END__

it's pretty much the same as:

if($var){
        print "hello world\n";
        $var++;
        print "hi world\n";
        print "last one\n";
}else{
        print "No!!!\n";
}

but it isn't the same of course(hey, there is no brackets right :-). the 
first version will probably run a bit faster if the optimizer doesn't 
covert the second version to the first one.

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to