use strict; use warnings; use Storable qw(store retrieve); my @cnt = -e 'file_count' ? @{ retrieve('file_count') } : ('') x 8; my $fcount; $fcount++ for glob('*'); unshift @cnt}, $fcount; pop @cnt; store(\@cnt, 'file_count');