http://qs321.pair.com?node_id=885285


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; } }