sub search_for_username_and_no_of_questions { my $username; foreach (@records) { if (/userName\s+:\[(..*)\]/) { ($username = $1) =~ s/\s+//g; } elsif (/Set\s+of\s+questions\(bitmap\)\s+selected\s+:\s+(\d+)/) { $no_of_questions{$username} = $1; $timestamp{$username} = $Time_Stamp; } } }