How do I use a perl variable name properly within backticks?

前端 未结 3 608
心在旅途
心在旅途 2020-12-30 04:01

I need to execute the following code on a bash shell:

mogrify -resize 800x600 *JPG

Since the width and height are variables, I tried this:<

3条回答
  •  醉话见心
    2020-12-30 04:11

    In addition to the other good responses, you can also use the readpipe function, which is equivalent to backticks and the qx operator. But like a regular function, you can exercise greater control over how the arguments to it are interpolated.

    $output = readpipe("mogrify -resize $wid" . "x$hit *.JPG");
    $output = readpipe( sprintf "mogrify -resize %dx%d *.JPG", $wid, $hit );
    

提交回复
热议问题