Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: regex backreference

by Kenosis (Priest)
on Nov 30, 2013 at 16:49 UTC ( #1065065=note: print w/replies, xml ) Need Help??


in reply to regex backreference

Perhaps the following will be helpful:

use strict; use warnings; my %seen; while (<DATA>) { !$seen{ $. . $1 }++ and print "Line $.: $1\n" while /(\b\w{3}\b)(?=.*\1)/g; } __DATA__ foofoo foo foo foo bar foo foo bar foo bar foooof foo oof foo and bar foo foo and and bar bar foo and bar foo and bar and or and or say or say or say or say

Output:

Line 2: foo Line 3: foo Line 4: foo Line 4: bar Line 8: foo Line 8: and Line 8: bar Line 9: foo Line 9: and Line 9: bar Line 10: and Line 10: say

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1065065]
help
Chatterbox?
[Corion]: Hi marto!
[Corion]: I just found out that in $current_top_prior ity_project , the part I am in is not even in the top three worries. That's somewhat bad, not because I'm happy with being a top worry but because that means that I don't even know how bad the rest ...
[Corion]: ... of the situation is :-)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-07-26 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (385 votes). Check out past polls.