PERL - Variable values getting mixed up!

Hi,

I only dip my toe into PERL programming on the odd ocassion so I was wondering if anyone had any ideas as to why the below is happening:
When I run my PERL script the variable values seem to get mixed up.

my $fileName = basename($maxFile,".TXT");
my $currentSeqNum = substr($fileName,-1,1);
my $nextSeqNum = ($currentSeqNum)++;
print "File Name: $fileName\n\n";
print "Current Sequence Num: $currentSeqNum\n\n";
print "Next Sequence Num: $nextSeqNum\n\n";

Which produces:

MaxFile: FOT05172.TXT
File Name: FOT05172
Current Sequence Num: 3
Next Sequence Num: 2

$maxFile gets it value from an sql query using DBI which is correct. The problem lies in the fact that the "Current Sequence Num:" and "Next Sequence Num:" values seem to be the wrong way round.
Can anyone spot a mistake in my code?

Thanks
Chris

Hi,

Issue is with the statement my $nextSeqNum = ($currentSeqNum)++;
It means first assign $currentSeqNum to $nextSeqNum and then increment $currentSeqNum.
Instead you could write like

 
my $nextSeqNum = $currentSeqNum;
print "Next Sequence Num: " ,++$nextSeqNum,"\n\n";

OR

 
my $nextSeqNum = $currentSeqNum + 1 ;
print "Next Sequence Num: $nextSeqNum\n\n";

~Pravin ~

Good spot, option B is what I was after.

Thanks