What happened?
>> What does: if (/^(\d+)/ && grep { /^\Q$1\E$/ } @numbers) { do? <<
Looping through the file assigns every line to $_ on every iteration of the loop and with regex $_ can be omitted, so:
/^(\d+)/
....is the same as saying "if this line begins with one or more digits"
......then the grep line is checking whether the id we found (which is now assigned to $1) ... exists in @numbers.
So to review here's how it looks as words....
"if this line begins with a number and the number can be found in @numbers then add that number into the @result_list array"
Maybe I misunderstood what you wanted it to do?
>> What does: if (/^(\d+)/ && grep { /^\Q$1\E$/ } @numbers) { do? <<
Looping through the file assigns every line to $_ on every iteration of the loop and with regex $_ can be omitted, so:
/^(\d+)/
....is the same as saying "if this line begins with one or more digits"
......then the grep line is checking whether the id we found (which is now assigned to $1) ... exists in @numbers.
So to review here's how it looks as words....
"if this line begins with a number and the number can be found in @numbers then add that number into the @result_list array"
Maybe I misunderstood what you wanted it to do?