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:<
This problem isn't specific to backticks. The problem can happen whenever you interpolate Perl variables in a string.
my $wid = 800;
my $hit = 600;
print "$widx$hit"; # this has the same problem
The problem is that the Perl compiler can't know where the variable name ("wid") ends and the fixed bit of the string ("x") starts. So it assumes that it is looking for a variable called $widx
- which doesn't exist.
The solution is to put the name of the variable in { ... }
.
my $wid = 800;
my $hit = 600;
print "${wid}x$hit"; # This works