Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: hash keys from another file

by choroba (Canon)
on Mar 23, 2013 at 12:31 UTC ( #1025030=note: print w/ replies, xml ) Need Help??


in reply to hash keys from another file

You do not need to load any file to an array. Just build a hash from the param file, then process the sent file line by line and output the count if you can find it:

#!/usr/bin/perl use warnings; use strict; my %counts; open my $PARAM, '<', 'param' or die "param: $!"; while (<$PARAM>) { my ($count, $word) = split; $counts{$word} = $count; } open my $SENT, '<', 'sent' or die "sent: $!"; while (<$SENT>) { chomp; print; print " $counts{$_}" if exists $counts{$_}; print "\n"; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: hash keys from another file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2015-07-04 23:11 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 (60 votes), past polls