Combine multiple statements into an expression in Perl?

207 views Asked by At

Is it possible to combine multiple statements into a single expression? A block could do this but I am wondering whether they could also be packaged into a expression.

1

There are 1 answers

0
ikegami On BEST ANSWER

That's exactly do BLOCK's purpose.

For example,

my $file = do {
   open(my $fh, '<', $qfn) or die $!;
   local $/;
   <$fh>
};