Then i got the number of instances using McDarren's code from Counting in regular expressions and did this:my $all = do {local $/; <IN>};
Is there a less troublesome way to do this? Even better, is there a way to correspond a hash key to an array value without "whiling" thru -- so i could invoke the number of occurances (from %hash) to the sorted array value (which would equal the name of a hash key)?#!/usr/bin/perl -w use strict; my $bit="ace"; my (%hash); while (<DATA>) { if ($_ =~ /$bit/) { my @ray=($_ =~ /$bit/g); my $c=scalar @ray; $hash{$_}=$c; } } my @rank=sort{$hash{$b}<=>$hash{$a}}keys%hash; print @rank; __DATA__ In the wire game, a "mob" composed of dozens of grifters simulates a "wire store", i.e., a place where results from horse races are received by telegram and posted on a large board, while also being read aloud by an announcer. The griftee is given secret foreknowledge of the race results minutes before the race is broadcast, and is therefore able to place a sure bet at the wire store. In reality, of course, the con artists who set up the wire store are the providers of the inside information, and the mark eventually is led to place a large bet, thinking it to be a sure win. At this point, some mistake is made, which actually makes the bet a loss.
In reply to ranking number of occurances by halfcountplus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |