Q:

How to append system date to a filename in perl ?

How to append system date to a filename in perl ? 
As i am very new to perl programming , can you give me a simple example for the above query.

A:

The strftime() function from the POSIX module gives an easy way to get a date in whatever format you want.
#!/usr/bin/perl

use strict;
use warnings;
use 5.010;
use POSIX 'strftime';

my $date = strftime '%Y-%m-%d', localtime;
say $date;

You can then use  that string in the filename of your file. If you are renaming a file, then you can use move() from the File::Copy module.

A:

This might help u out!
#!/usr/bin/perl
my $date=`date +%Y%m%d`;
chomp($date);
my $source_file="/tmp/fileName_.tgz";
my $destination_file="/misc/fileName_" . $date . ".tgz";
print "$source_file\n";
print "$destination_file\n";
system("sudo mv /tmp/fileName_.tgz /misc/fileName_$date.tgz");

or try this
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900; 

my $out = "$dir/$host-$mday-$mon-$year"

or this one
# grab the current time
my @now = localtime();

# rearrange the following to suit your stamping needs.
# it currently generates YYYYMMDDhhmmss
my $timeStamp = sprintf("%04d%02d%02d%02d%02d%02d", 
                        $now[5]+1900, $now[4]+1, $now[3],
                        $now[2],      $now[1],   $now[0]);

# insert stamp into constant portion of file name.
# the constant portion of the name could be included 
# in the sprintf() above.
my $fileName = "File$timeStamp.log";

