Your request concerning the date/time stamp is not clear to me. I have guessed that you wish to replace the current date/time stamp with a new one showing the current date/time. Apologies if that is incorrect, please clarify what you are trying to do. Anyway, here is my guess:
use strict;
use warnings;
use POSIX qw(strftime);
# Open the file for read and write
open (my $fh, '+<', 'data.dat') or die "Unable to open data.dat: $!";
# Specified: day/month/yyyy h:m:s am or pm
# assumed dd/mm/yyyy hh:mm:ss am/pm
my $new_stamp = strftime ('%d/%m/%Y %I:%M:%S %p',localtime);
# This gets AM/PM insteam of am/pm, so:
$new_stamp =~ s/([PA]M)$/lc $1/e;
while (<$fh>) {
# Replace date/time stamp with new one
if (s|\d\d/\d\d/\d\d\d\d \d\d:\d\d:\d\d [ap]m|$new_stamp|) {
seek ($fh,-length($_)-1, 1);
print $fh $_;
}
}
close ($fh)