use warnings; use strict; use diagnostics; open (RECORD_NUMBER, "counter_data.dat") or die; my $count = ; # Lexical declaration to keep 'strict' happy. $count = $count + 1; print RECORD_NUMBER "$count"; close (RECORD_NUMBER) or die;