bd1257
bd1257

Reputation: 161

How to do command substitution in perl?

Basically in shell will do command substution like this

a=`uname -a`  

then how to do in perl?

Upvotes: 2

Views: 1993

Answers (2)

Borodin
Borodin

Reputation: 126722

It's pretty much identical in Perl -

$a = `uname -a`;

but, as @William Purcell says, qx is the same and more readable.

Upvotes: 5

William Pursell
William Pursell

Reputation: 212248

$a = qx( uname -a )

The qx operator is the same as backticks, but far more readable.

Upvotes: 9

Related Questions