in reply to variable inside a string inside back ticks
I will answer your question below, but first, I strongly recommend not to use backticks to run shell commands for things you can do in Perl! For date/time handling, I prefer DateTime, but in this case you can probably just use the core module Time::Piece, plus the Perl builtin glob (Update: Make sure to read File::Glob, though, as it's got some caveats in regards to whitespace, which is why I use File::Glob ':bsd_glob' in the code):
use warnings; use strict; use Time::Piece; use File::Glob ':bsd_glob'; my $today = localtime->strftime('%Y%m%d'); my $filename = glob('electric_inventory_WE_'.$today.'*.dat');
I wrote about backticks and the potential security issues with them here.
The problem you are having with the code you showed can be solved by looking at item 3 on the Basic debugging checklist (unexpected whitespace), and using chomp on those variables.
|
|---|