I'd write that as
my $x = do { open my $fh, '<', '/path/to/foo.file' or die $! <$fh>; };
Note that $fh is auto-closed due to falling out of scope.
Update: the last line was not meant to be $x = <$fh> of course.
Makeshifts last the longest.
In reply to Re^2: my $x = <expr>; vs my $x; $x = <expr>;
by Aristotle
in thread my $x = <expr>; vs my $x; $x = <expr>;
by jht
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |