ada has asked for the wisdom of the Perl Monks concerning the following question:
my %csahash; my $line=<>; while($line=<>){ if($line=~ /\b(\d\w{3})\b/){ $csahash{$1}++; } }
2buf= 48 1lsj= 6 2bp7= 12 1ye6= 36 8icc= 1 1a2n= 4 1lz6= 2 1pw1= 5 1e4d= 4 2f8j= 28 1iw8= 24 1qbd= 2 1kf4= 7 1z53= 3 1gxx= 2 1dd6= 10 1ke5= 10 2og7= 1
I have a very similar %hash like this:
%cathhash; my $line2=<>; while($line2=<>){ if($line2=~/\b(\d\w{3})\b/){ $cathhash{$line2}++; } }
my %csahash; my $line=<>; while($line=<>){ if($line=~ /\b(\d\w{3})\b/){ $csahash{$1}++; } } %cathhash; my $line2=<>; while($line2=<>){ if($line2=~/\b(\d\w{3})\b/){ $cathhash{$line2}++; } } foreach my $key(keys %csahash){ if(defined $cathhash{$key}){ print "$key matches. It's values are $csahash{$key} and $cathhash{$key +}\n"; } }
but when I try to execute it on the command prompt like this :
perl pl.pl csa.txt cath.txt I get nothing just a blank cursor. do I have to do something with cntrl+D? I am bit new to perl so am having teething problems. Many thanks. Ok, thanks again but when I run this code through I still get no print out, can someone tell me where I'm going wrong in my execution?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash question
by moritz (Cardinal) on Dec 11, 2007 at 10:46 UTC | |
|
Re: hash question
by cdarke (Prior) on Dec 11, 2007 at 12:50 UTC | |
|
Re: hash question
by olus (Curate) on Dec 11, 2007 at 11:50 UTC | |
by johngg (Canon) on Dec 11, 2007 at 12:41 UTC |