Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Extract Tags between Two strings

by fishmonger (Hermit)
on Jun 11, 2012 at 15:27 UTC ( #975595=note: print w/ replies, xml ) Need Help??


in reply to Extract Tags between Two strings

Here's an example using the flip-flop (range) operator.

#!/usr/bin/perl use 5.10.0; use strict; use warnings; my %wanted; while (my $line = <DATA>) { if ( $line =~ /\[start\]/ .. $line =~ /\[end\]/) { next if ($line =~ /\[start\]/ or $line =~ /\[end\]/); chomp $line; $wanted{$line}++; } } say $_ for sort keys %wanted; __DATA__ [start] bbc_arc_001 bbc_arc_002 abc_arc_001 [end] bbc_arc_001 bbc_arc_002 bbc_arc_003 bbc_arc_004


Comment on Re: Extract Tags between Two strings
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-08-01 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls