in reply to Is this Possible?

$. can only be used while still reading the file.
open my $LOG, '<', $logfile or die $!; my %occurrences; while (my $line = <$LOG>) { if ($line =~ /^$FAILURE_SEARCH /) { chomp $line; $occurrences{$.} = $line; } } return \%occurrences

When iterating over an array, you can use the index:

my %occurrences; for my $index (0 .. $#log) { if ($log[$index] =~ /^$FAILURE_SEARCH /) { $occurrences{ 1 + $index } = $log[$index]; } } return \%occurrences

Warning: untested code!

Update: Tested, fixed errors (missing argument to chomp, missing + 1 for the array index.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ