Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: statistics of a large text

by perl_lover_always (Acolyte)
on Jan 31, 2011 at 14:51 UTC ( [id://885285]=note: print w/replies, xml ) Need Help??


in reply to Re: statistics of a large text
in thread statistics of a large text

How can I use search::dict while my line is like this:
"$key\t@numbers" ?
example:
the\t1 5 8 34 56 the one\t1 5 56 the one of\t1 56
I want to search for "the one of" and retrieve "1 56" or an array including 1 and 56. Thanks alot in advance.

Replies are listed 'Best First'.
Re^3: statistics of a large text
by tilly (Archbishop) on Feb 01, 2011 at 07:21 UTC
    Assuming that you've done a use Search::Dict; and $fh is an open filehandle to your file then (untested code written by drunk person alert):
    sub match { my $string = quotemeta(shift); Search::Dict::look($fh, $string); my $next_line = <$fh>; if ($next_line =~ /$string: (\d+\s*)+/) { return split /\s+/, $1; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-19 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found