ctp has asked for the wisdom of the Perl Monks concerning the following question:
As you can see I haven't implemented the slurp yet, but I did get nnn'n words to work, and I now have a hash with word keys and count values. I went for the foreach instead of the map for now. I'll play with map (and grep) later. It may be all downhill from here, so many thanks to everyone who helped...I learned a ton!#! usr/bin/perl #midterm part 1 use warnings; open (TEXTFILE, 'text.txt') or die ("Cannot open file : $!"); $big_string = <TEXTFILE>; $big_string = lc ($big_string); $big_string =~ s/\(|\)/ /g; @words = split (/[,.\s+]/, $big_string); foreach (@words){ push @gt_three_char_words, $_ if /[a-zA-Z]{4,}|[a-zA-Z]{3,}'/; } foreach (@gt_three_char_words) { $hash{$_}++; } foreach (%hash) { print $_, "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: tutelage needed
by Zaxo (Archbishop) on Jan 01, 2004 at 02:18 UTC | |
by ctp (Beadle) on Jan 01, 2004 at 03:16 UTC | |
by Trimbach (Curate) on Jan 01, 2004 at 05:12 UTC | |
by ctp (Beadle) on Jan 01, 2004 at 05:34 UTC | |
Re: tutelage needed
by pg (Canon) on Jan 01, 2004 at 01:31 UTC | |
by ctp (Beadle) on Jan 01, 2004 at 01:41 UTC | |
Re: tutelage needed
by jweed (Chaplain) on Jan 01, 2004 at 02:15 UTC | |
by ctp (Beadle) on Jan 01, 2004 at 02:54 UTC | |
by jweed (Chaplain) on Jan 01, 2004 at 03:00 UTC | |
by ctp (Beadle) on Jan 01, 2004 at 03:19 UTC | |
by jweed (Chaplain) on Jan 01, 2004 at 07:22 UTC | |
| |
Re: tutelage needed
by toma (Vicar) on Jan 01, 2004 at 17:54 UTC | |
Re: tutelage needed
by injunjoel (Priest) on Jan 01, 2004 at 23:23 UTC | |
by ctp (Beadle) on Jan 04, 2004 at 06:07 UTC |