G'day Richard,
Passing embedded code in filenames is probably not the best course of action. I suspect what you really want is something more like:
$ perl -E ' my ($d, $m, $y) = (localtime)[3..5]; say $ARGV[0], "_", $d, $m+1, $y+1900, ".log"; ' filename filename_17122019.log
However, to answer your specific question, you'd probably want string eval. Do read that documentation closely for all sorts of things to be aware of. It's generally best to avoid string eval unless you have no other recourse. Here's an example of how it might work in your scenario.
$ perl -E ' my $x = $ARGV[0]; my ($start, $middle, $end) = $x =~ /^([^`]+)(.+?)([^`]+)$/; chomp(my $mid_eval = eval $middle); say $start, $mid_eval, $end; ' 'filename_`date +%d%m%Y`.log' filename_17122019.log
Note that I didn't need two levels of quotes.
— Ken
In reply to Re: backticks execution "inside" variable (string)
by kcott
in thread backticks execution "inside" variable (string)
by richard.sharpe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |