Well, the obvious answer is to save the template in a file and insert the correct numbers. For instance:
echo abc_%s_cde_%s_fgh_include_internal | perl -MPOSIX -nE 'say sprintf $_, strftime("%Y%U", localtime()), "07";'
Output:
abc_201207_cde_07_fgh_include_internal
So, if you have a template file, you can use %s to insert lines and provide arguments from your own argument list, or dynamically, as you prefer. For instance:.
my $year = "2011"; my $week = "49"; my $ver = "07"; # Strings or numbers does not really matter open my $fh, '<', "sdk_link.txt" or die $!; while (<$fh>) { my $file = sprintf $_, $year, $week, $ver; copy($file, "/testing") or die "Copy failed for file $file: $!"; }
I'm not sure if File :: Copy :: copy works as intended for deleted files, but that is another question. I believe Net :: FTP :: get () may be what you want.
source share