Attention-To those who helped me out before thanks. I got the work project done.

Trying to figure out this book challenge from last semester. I never completed it. Any advice?

From what I see I have it completely done, but two parts still confuse me. I like to do these assignments, as I can help out other students having issues. Perl isn't my thing, but I assist where I can.

The point of the assignment is to take a txt document and then print out all the words, first from A-z and then based on occurrences of numbers greatest to least.

My problem is this only picks up words that have nothing following it or before it. so "search works", not "search, or search." Does REGEX and Split use similar commands?

foreach my $word (split /\s+/, $fname)

Second I'm trying to recall how I can do the count from greatest to least without an array.

for $word (sort keys %counter) { print "$counter{$word}\t$word\n"; }

Code

use strict;

my $fname; #my @file; my $line; my $word;

#sets fname as ARGV[0] in the command line. $fname=$ARGV[0];

open IFILE,"<",$fname; #@file = <IFILE>; close IFILE;

#ARGV acquistion of the input file open IFILE,"<",$fname;

#identify if the filename is actually there. if (!(-e $fname)) { print "File $fname does not exist\n"; exit; }

# If too many parameters are specified (more than 1) an error message is displayed and the program terminates. if ($#ARGV!=0) { print "Usage error. Syntax is filename.pl inputFile.txt\n"; exit; }

Again, you have pure words which you can store in an hash for further processing.

There might be a couple of issues, though, with "words" containing apostrophies ("you're doing this") or hyphens ("post-increment"). So you might have to refine your regular expressions to tackle these specific cases.