#!/usr/bin/perl #----------------------------------------# # Color Text: Perl Cookbook, pg 522 # #----------------------------------------# use Term::ANSIColor; # Clear the screen with the system call `clear` system (clear); print color("red"), "###############################################################",color("reset"),"\n", color("white"), "Presenting: ",color("reset"),"\n", color("white"), " Exersize 4.12 Problem 2 ",color("reset"),"\n", color("red"), "###############################################################",color("reset"),"\n", color("white"), "Generate a master word file: \`aspell dump master \>dictionary.txt",color("reset"),"\n", color("white"), "1 Read in dictionary file. ",color("reset"),"\n", color("white"), "2 Sort words by word length ",color("reset"),"\n", color("white"), "3 Write words of same length to the same file. ",color("reset"),"\n"; # Open the dictionary file or bust. open (DICTIONARY, "){ # assign the word to a variable cause $_ is not working $word="$_"; chomp ($word); # determin the word length my $length=length($word); # open, append, and close, the word to the approprate file. open (WORDFILE, ">>chars\_$length\.txt" ) || die "Could not open chars\_$length\.txt:\t$!\n"; print WORDFILE "$word\n"; close (WORDFILE) || die "Could not close the file chars\_$length\.txt:\t$!\n"; } close (DICTIONARY) || die "Could not close dictionary.txt:\t$!\n"; print color("green"), "ALL DONE! List the directory",color("reset"),"\n"; ############################################################### Presenting: Exersize 4.12 Problem 2 ############################################################### Generate a master word file: `aspell dump master >dictionary.txt 1 Read in dictionary file. 2 Sort words by word length 3 Write words of same length to the same file. ALL DONE! List the directory # these are my files ls char* chars_1.txt chars_11.txt chars_13.txt chars_15.txt chars_17.txt chars_19.txt chars_20.txt chars_22.txt chars_24.txt chars_3.txt chars_4.txt chars_6.txt chars_8.txt chars_10.txt chars_12.txt chars_14.txt chars_16.txt chars_18.txt chars_2.txt chars_21.txt chars_23.txt chars_28.txt chars_30.txt chars_5.txt chars_7.txt chars_9.txt