Passing perl variable to shell command

Can we pass perl variable to shell commands. If yes, please give some example.

How about this: get a variable named var in perl into PERL_VAR:

PERL_VAL=$(perl -e 'my $var="200" ; print $var')

Or did you mean somthing like this

my $file1="source";
my $file2="dest";
 
system("/usr/bin/cp", $file1, $file2);
1 Like

Thanks for the reply.

But i want to use in open().

open(PS,"cmd  |") || die "Failed: $!\n";