Hello jasper8989, and welcome to the Monastery!
Your code actually works fine for me. But note that each $zipcode and $line terminates in a newline character. It is better practice to chomp each line of input to remove the terminal newline. It’s possible that your problem stems from a newline mismatch between the lines in the first and second loops.
So, you should begin by verifying that @zipcodes contains the data you expect it to. Print out the contents immediately following the first while loop. See Data::Dumper or (my preference) Data::Dump. Likewise, check the contents of $line on each iteration of the second while loop.
Here are two useful references: Basic debugging checklist and Unbelievably Obvious Debugging Tip.
Update: Added the second reference.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: regex matching array values with foreach
by Athanasius
in thread regex matching array values with foreach
by jasper8989
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |