Hello friends,
having another appetizer: I am reading lines from file, whose name contains backticks, with exact name e.g.:
filename_`date +%d%m%Y`.log
I am providing it to Perl script on (Bash) command line this way, to avoid early backticks execution - I don't want shell to execute them, but Perl, later:
script.pl '"filename_`date +%d%m%Y`.log"'
Note the two levels of quotes - single and double - I don't insist on doing it this way, it was just the first successful try how to force Perl not cutting filename after date, because followed by space.
I am processing that input in the script this way (shortened):
my @in_files = (); foreach my $input_glob (@ARGV) { print $input_glob; push @in_files, glob("$input_glob"); } # reading and storing lines foreach my $in_file (@in_files) { open (LINES, '<', $in_file); ...
After having read, I want to write contents to another file, but now with those backticks executed/interpolated (with current date for purposes of this example).
my $out_file = "/other/path/$in_file"; # this opens file ... open (LOGFILE, '>>', $out_file); # ... but still without backticks execution/interpolation
My question is maybe more general, than illustrated in example above: is there a way (ideally simple) how to instruct Perl to execute backticked substring of some variable and interpolate it with the execution result?
Thank you.
Richard
In reply to backticks execution "inside" variable (string) by richard.sharpe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |