On 2018-11-21 3:08 a.m., Amanda Paziuk wrote:
I'm hoping someone can assist as I'm having difficulty with parsing a section of the following configuration: This is the code I have: push @list, $datum; # should only contain '1', and '3'
> > ... >
foreach my $i (@list){ # loops through dynamically-learned file IDs open (IN, $file); while (<IN>) { chomp; if (/^ file-id $i/) {
If $i contains 1 then this will match "file-id 10" or "file-id 1234" or any number whose first digit is 1.
You need to either use anchors: if ( /^ file-id \b$i\b/ ) { Or capture the number and do numerical comparison: if ( /^ file-id (\d+)/ && $1 == $i ) { John -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/