Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Help with perl error message

by frankus (Priest)
on Jun 25, 2002 at 13:21 UTC ( #177080=note: print w/ replies, xml ) Need Help??


in reply to Help with perl error message

Thought of trying use diagnostics;?
Also consider moving those arrays to anonymous arrays in a hash.

# List all search criteria
my @search = ( 'CCFN\d+NT','CCFN',
               'EBGFN','EBG',
               'PRFN','PR',
               'BLSTDGG','BLSTDG','BL');

# Build an index of the fields they correspond to
my %index = map{ $earch$_ => $_ } (0..$#search);

# Make a hash to store the results
my %results = map { $_ => [] }@search;

# Make a generic regex, for one pass.
my $regex = join( '|' map{"($_)"}@search);

# Blah blah split and stuff. 

# Use the bracketed results of the regex to store data.
m/$regex and push @{$results{$1}}, $line[$index{$1};

print Dumper \@results{@search};

--

Brother Frankus.

¤


Comment on Re: Help with perl error message
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2015-07-02 23:58 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 (47 votes), past polls