for my $field ( @field_names ) { if ( s/.*?\s$field:\s+([\d.]+)//s ) { $field_val{$field} = $1; } }