in reply to matching lines in multi-line string

@patternMatchArray = $lines =~ /pattern/mg;
Update: Just an idea on how to solve the problem, not the final solution. I forgot to mention that. ;-)

Replies are listed 'Best First'.
Re: Re: matching lines in multi-line string
by edan (Curate) on Nov 27, 2003 at 12:29 UTC

    Wrong. This will give you an array of substrings that were matched by the pattern. The requirement is to get the lines that match the pattern.

    You could change it to

    @patternMatchArray = $lines =~ /^.*pattern.*$/mg;

    But it doesn't seem like a good solution to me, though I can't put my finger on exactly why not...

    --
    3dan

      Well, doesn't this look rather like a homework question to you??? Of course I know that solution doesn't solve the problem. I was just giving him an idea of how to tackle the problem, not to give him a staight answer. I think OP is doing it that way (using slurp and regular expression) for a reason. ;-)