Rob Dixon wrote: >> you want to know what's failing, right? > > Wrong. John was just pointing out that $1 would remain > defined from a previous regex match in my previous post. > This would mean that there was no way of telling in > retrospect if the match had suceeded. The context of > the problem was vague anyway, and I was supposing that > the match in question would be within a 'while' block.
ok. and yeah, it depends on what you're looping around :) > My solution above leaves $newdata undefined if the > match fails, and is a better generalisation as the > surrounding code has all the information it could > need (including the original $data value). right same as the below, however in the case of my suggestion, I regularly do this sort of thing during testing phases to determine if the data-set contains any unexpected data I need to know about. :-) >> unless ($data =~ m/ <([^>]*)> /x) { >> warn "## Error matching regex in '$data'"; >> next; >> } >> $newdata = $1; > > This is the same as one of my musings above: > > $data =~ m/ <([^>]*)> /x or next; > > apart from the warning call. right. except if you want that to work I'd recommend getting in the habit of doing the following, which can be particularly important if you are extracting multiple matches to different variables ($data) = ~ m/\s<([^>]*)>\s/x or next; It's also not a bad idea to get in the habit of being explicit about whitespace (via \s) as Perl 6 regular expressions will ignore whitespace by default. Get in the habit now, and you won't have to re-learn and re-train yourself later. :) (cue the ominous foreshadowing music) ... Cheers, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]