Perl script to change the date in some scenario

Hi ,

I have file FSN.log which contains number 100. i have other Perl script when i run it , it ll increment this FSN.log value.

now my requirement is
when the count in FSN.log becomes 999, it should make the value to 100 again and Perl script to change the date or it should make the date field value as previous or something and it should remain the same..

anyone can help with this ?

Thanks

Okay. Please show sample input and sample expected output.

What have you tried so far?

#!/usr/bin/perl -w

# Print the value of the command line arguments
$FSNCount = $ARGV[2];
#print "Replacing all QQQ in $ARGV[0] - with $FSNCount in $ARGV[1]\n";
$DateField=`date +%Y%m%d`;
chomp ($DateField);
$TimeField=`date +%H%M`;
chomp ($TimeField);
open INPUTFILE, $ARGV[0] or die $!;
open OUTPUTFILE,">$ARGV[1]" or die $!;
# Read the input file line by line
while (<INPUTFILE>)
  {
    $_ =~ s/QQQ/$FSNCount/g;
    $_ =~ s/YYYYMMDD/$DateField/g;
    $_ =~ s/HHHH/$TimeField/g;
    print OUTPUTFILE $_;
  }
#while (<INPUTFILE>)
#  {
#  }
print "\t $DateField\n";
print "\t $TimeField";
close INPUTFILE;
close OUTPUTFILE;
~

This is wat i have tried

---------- Post updated at 04:51 PM ---------- Previous update was at 04:42 PM ----------

initially FSN count =100 and date value ll become current date but when FSNCOUNT = 999 , Date field should be changed to previous day s date and again FSN count should become 100...and the date value should be previous day only till it reach 999 again. so on

eg : FSN COUNT =100 , date= 20130102
      FSNCOUNT=101, date = 20130102
     ....
     ....
     FSN COUNT =999, date= 20130102 and FSN COUNT should become 100

and from next time date=20130101
so next time

FSNCOUNT=100, date = 20130101
....