in reply to Pattern matching

You appear to be using a C-style loop:

if($array[$i] =~ /Check-->\s*\d+$/) # ^ C style loop counter?
Sometimes, that's the (only) way to go, but generally, a more idomatic approach is:

for my $array(@array) { chomp $array; # may be unnecessary for your aplication if ($array =~ /check-->(\S*\d+)(?:\])$/i) { # \S Not-a-space, / +i case insensitive # ^ also un-needed, for data shown, +but a precaution # against some possible elements in +your __DATA__ my $output = $1; # Good approach; avoids reusing a left-ove +r match