Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Generalizing Regex with Multiple Match

by prasadbabu (Prior)
on Nov 25, 2008 at 08:51 UTC ( #725795=note: print w/ replies, xml ) Need Help??


in reply to Generalizing Regex with Multiple Match

Hi neversaint,

You have to add while statement to get all the matches.

use strict; use warnings; use Data::Dumper; my %all_entry; while (<DATA>) { chomp; next unless (/^>/); my $line = $_; while ($line =~ /GI\=(\d+)\,(\w+)\,(\d+\-\d+)/g){ push @{ $all_entry{$1}{$2} }, $3; } } print Dumper \%all_entry; output: ------- $VAR1 = { '162960844' => { 'bw' => [ '0-4', '9025576-9025608' ] }, '152989753' => { 'bw' => [ '0-30', '1877925-1877931' ] } };

Prasad


Comment on Re: Generalizing Regex with Multiple Match
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2015-07-06 11:07 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 (72 votes), past polls