in reply to Re: Did not get the regex matched value in perl array variable
in thread Did not get the regex matched value in perl array variable

Yes, Marshall, you're right that storing the content of the file in an array and then grepping the array essentially means looping twice over the data (which can be inefficient with large data). The problem is not so much due to grep, however, but to the use of a temporary array to store the contents of the file.

You could use grep without incurring the cost of two implicit loops by removing the use of a temporary array:

my @queue = grep { /count=\s*(\d+)/; $1 } <DATA>;