Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Text::Prefix::XS 0.15

    Download button

    No screenshots available
    Downloads: 106  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Mark Nunberg | More programs
    Perl Artistic License / FREE
    December 28th, 2011, 18:11 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Text::Prefix::XS description

    Fast prefix searching

    Text::Prefix::XS is a Perl module that implements something of an trie algorithm for matching (and extracting) prefixes from text strings.

    A common application I had was to pre-filter lots and lots of text for a small amount of preset prefixes.

    Interestingly enough, the quickest solution until I wrote this module was to use a large regular expression (as in the synopsis)

    SYNOPSIS

     use Text::Prefix::XS;
     my @haystacks = qw(
     garbage
     blarrgh
     FOO
     meh
     AA-ggrr
     AB-hi!
     );
     
     my @needles = qw(AAA AB FOO FOO-BAR);
     
     my $search = prefix_search_create( map uc($_), @needles );
     
     my %seen_hash;
     
     foreach my $haystack (@haystacks) {
     if(my $prefix = prefix_search($search, $haystack)) {
     $seen_hash{$prefix}++;
     }
     }
     
     $seen_hash{'FOO'} == 1;
     
     #Compare to:
     my $re = join('|', map quotemeta $_, @needles);
     $re = qr/^($re)/;
     
     foreach my $haystack (@haystacks) {
     my ($match) = ($haystack =~ $re);
     if($match) {
     $seen_hash{$match}++;
     }
     }
     $seen_hash{'FOO'} == 1;



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    prefix searching | Perl module | trie algorithm | Perl | prefix | search

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM