Avoiding intermediate variables with chomp()

Question

I can do this:

chomp(my $ps = `which ps`);   #chomp that system-call linefeed!
my %hash = (key => $ps);

But what I really want to do is something like this:

my %hash = ( key => chomp `which ps`);

(One command, no intermeditate variable) but Perl hates my syntax (and the several similar variants I've guessed at, playing with different parenthesis groupings).

Does anyone know the proper syntax?

David Filmer's original post

Next