in reply to Re: Help to build a REGEXP
in thread Help to build a REGEXP

Hi, I tried:
if($_=~ m/^\s+\/translation\=\"(.*?)\"/ms) { $wanted_part=$1; }

but got nothing! But why doesn't it work?

Replies are listed 'Best First'.
Re^3: Help to build a REGEXP
by Anonymous Monk on Mar 12, 2014 at 10:57 UTC
      I can easily match the wanted part, if I slurp the whole entry in one variable, using the $/ operator...
      But problem is that the teacher is a bit weird and thinks these are "non-pedagogical stuff"...
      Inside $_ it's only each current line of the entry, nothing more...

        I can easily match the wanted part, if I slurp the whole entry in one variable, using the $/ operator... But problem is that the teacher is a bit weird and thinks these are "non-pedagogical stuff"... Inside $_ it's only each current line of the entry, nothing more...

        In that case think harder

Re^3: Help to build a REGEXP
by kcott (Archbishop) on Mar 12, 2014 at 20:18 UTC

    It doesn't work because your regex doesn't match whatever is in $_. Of course, as you've refused to advise us what $_ contains, you can't possibly expect any further information on what was happening in that isolated code fragment.

    I provided you with a solution. Your response says you tried something completely different. Why did you reply to my post telling me that?

    Did you try my solution? Did it do what you wanted? If not, what did it do differently? Was it unsuitable for your class exercise? If so, in what way was it unsuitable?

    You've failed to tell us what data you're actually trying to match against: first with $line7 and more recently with $_. Why? I even gave you the specific code in my earlier response " (i.e. print "$line7\n";)". Did you do this? If you did, what was the output? If you didn't, why not?

    You've received a lot of advice from people who've freely given their time to try to help you. I think its about time you put in some effort yourself: answer questions, provide output, try solutions and so on.

    -- Ken