Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: What does 'global' (/g) do in a regexp in this particular case?

by choroba (Abbot)
on Apr 09, 2013 at 13:41 UTC ( #1027739=note: print w/ replies, xml ) Need Help??


in reply to What does 'global' (/g) do in a regexp in this particular case?

As already explained, the /g remembers the position where the last match succeded in $Column. As a workaround, you can use double quotes to make the strings "not the same string":

if (((("$Column" =~ m/Property/gs))))
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: What does 'global' (/g) do in a regexp in this particular case?
Select or Download Code
Re^2: What does 'global' (/g) do in a regexp in this particular case?
by LanX (Canon) on Apr 09, 2013 at 13:44 UTC
    > As a workaround

    ehm, ok! But what for???

    Can't see any benefit of using /g here.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    Update

    OK at least in a loop pos works on literals...

    DB<139> print scalar "a a" =~ /a/g for 1..10 1111111 # third iteration is undef than restart from beginning DB<140> print scalar "a a" =~ /a/ for 1..10 1111111111 # infinite restart
Re^2: What does 'global' (/g) do in a regexp in this particular case?
by Anonymous Monk on Apr 09, 2013 at 13:52 UTC
    $Column is already a different string, DreamT has tripped /g in list context bug -- interpolation breaks aliasing/ causes copying -- jumps out of the bug
      Where is the list context?
      perl -E '$x = "12345"; $a = $x =~ /4/g; $b = $x =~ /1/g; say "$a,$b.\n +"'
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027739]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (18)
As of 2014-07-23 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (146 votes), past polls