I want to delete all fiels with the filenaming convention HRPAY.sss.yymmdd where HRPAY is constant, sss and dd are numbers and yymm is dynamically figured out - 2 digit year and 2 digit month.
this is a piece of perl script I have written to delete remote files with wild card and a pattern. the pattern
"HRPAY*${gv_month}*" is not correct. how can I specify it?
#!/opt/perl/bin/perl -w
if ($ftp = Net::FTP->new($gv_ftp_host) ) {
print "Logging in to '$gv_ftp_host' as user '$user'.\n";
$ftp->login($user,$pw) or die "Could not login";
$ftp->pasv();
print "Changing directory to '$p_ftp_archive_location'\n";
$ftp->cwd($p_ftp_archive_location) or die "could not cwd $p_ftp_archive_location";
my @files = $ftp->ls("HRPAY*");
print "Found these files: \n\t" .
join( "\n\t", @files ) .
".\n";
foreach my $file (@files) {
if ( $file = "HRPAY*'${gv_month}'*" ) {
print "Deleting file: $file.\n";
$ftp->delete($file) or print "Could not delete $file\n";
}}
$ftp->close(); }
else { print "Could not connect.\n"; }
thanks.