in reply to need help on declaring variables

$_ =~ m/^(.*) UTC.*refs = (\d+)$/; my $dt = $Strp->parse_datetime($1); my $timestamp = $dt ->epoch(); my $refs = $2;

...third (in addition to what ysth said), don't use $1, $2, etc. after some code which could have modified those variables in the meantime (like the $dt->epoch() call here — I'm not saying that it did modify $2, but code under the hood of that call could have...). Best only use them immediately after the match, or store the value away in some other variable.