in reply to Remove all duplicates after regex capture

Another idea for you:
I think it is straightforward and "simple" in concept.
#!/usr/bin/perl use strict; use warnings; my %mycorpus = ( a => "<blah blah blah blah title:#this is text I want 1# blah blah blah", b => "blah title:#this is text I do not want# blah title:#this is text I want 2# blah title:#this is text I do not want# blah", c => "blah blah title:#this is text I want 3# title:#this is text I do not want# title:#this is text I do not want# title:#this is text I do not want# blah", ); foreach my $filename (sort keys %mycorpus) { foreach my $line (split /\n/,$mycorpus{$filename}) { if ($line =~ /^title:#(.*)#\s*$/) { print "$line\n"; last; } } } __END__ title:#this is text I want 1# title:#this is text I want 2# title:#this is text I want 3#

Replies are listed 'Best First'.
Re^2: Remove all duplicates after regex capture
by Maire (Scribe) on Aug 20, 2018 at 06:59 UTC
    Thank you!