in reply to Threading two text files

some suggestions:

HTH =)

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: Threading two text files
by LanX (Saint) on May 15, 2013 at 10:43 UTC
    > if speed matters consider reading both files first, if you put the data of the second into a hash you can check much faster.

    like this

    use strict; use warnings; use Data::Dump qw/pp/; open my $qqq,"<","qqq.txt" or die "Open qqq failed $!"; open my $exp,"<","exp.txt" or die "Open exp failed $!"; my @exp = <$exp>; chomp @exp; my %qqq; while (<$qqq>) { my ($value,$key) = split /\s+/; push @{$qqq{$key}},$value; } #pp \%qqq,\@exp; print "$_: @{$qqq{$_}}\n" for @exp;

    out

    a: 1 11 c: 333

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re^2: Threading two text files
by ostra (Novice) on May 15, 2013 at 17:51 UTC

    Thank you for the help. The issue was definitely not haveing <INDB> in the seek function. I saw that other PerlMongers caught this as well. I will definitely look at your version of code(as well as other Monger code and compare this with my version. But all am trying to do is search a number of values against a database and display the matches. The code I wrote for this worked well after the correction. The hash will not work for me as my database will contain more than one key value pair.Again thank you for your input. Ostra

      > The hash will not work for me as my database will contain more than one key value pair.

      Sure it does! =)

      It's a HoA (hash of arrays) holding all values per key, check the example output and uncomment pp to see the data structure.

      Cheers Rolf

      ( addicted to the Perl Programming Language)