Sam said:
You can use any expression, "command" is a meaningless term in
that context.
You can use operators like , to turn multiple expressions into
one expressions, and functions or do to turn arbitrary
statments into an expression.
Though using if..else will usually make for more readable
code, if the expressions are large.
Here is the code I'm trying to get to work:
my $firstdept=1;
foreach my $app (keys %appdept_percentage){
my $applen=length($app)+4;
$firstdept?$firstdept=0,printf "\n%35s",$app

rintf
"%".$applen."s",$app
}
Admittedly I could write it:
my $firstdept=1;
foreach my $app (keys %appdept_percentage){
my $applen=length($app)+4;
$firstdept?printf "\n%35s",$app

rintf "%".$applen."s",$app
$firstdept=0;
}
OR
my $firstdept=1;
foreach my $app (keys %appdept_percentage){
my $applen=length($app)+4;
if (){
printf "\n%35s",$app
$firstdept=0;
}
else{ printf "%".$applen."s",$app
}
}
OR probably a dozen other ways, but my simple question is assuming I
could do this, what is the correct syntax to group this
$firstdept=0,printf "\n%35s",$app
between the ? and :
This is syntactically wrong at the moment:
$firstdept?$firstdept=0,printf "\n%35s",$app

rintf "%".$applen."s",$app
This won't work:
$firstdept?$firstdept=0 && printf "\n%35s",$app

rintf "%".$applen."s",$app
Nor will this:
$firstdept?($firstdept=0,printf "\n%35s",$app)

rintf "%".$applen."s",$app
or this:
$firstdept?{$firstdept=0,printf "\n%35s",$app}

rintf "%".$applen."s",$app
I don't care about legibility, I just want to know if Perl can do it or
not?!!!!!!
Thanks,
JS.