Yoda_Oz has asked for the wisdom of the Perl Monks concerning the following question:
here is the output i get with a particular file:#!usr/local/bin/perl use strict; use warnings; my %wordHash; my @wordArray; print ("Enter filename to search for punctuation characters: "); my $path=<STDIN>; print ("\n"); open(DATA, "<$path") || die "Couldn't open $path for reading: $!\n"; while (<DATA>) { while (s/([\041-\057]|[\72-\100]|[\133-\140]|[\173-\176])(.*)/$2/) { my $count = $1; $wordHash{$count}++; } } close (DATA); my %charnames = ( '?' => 'question mark', '.' => 'fullstop', ',' => 'comma', '(' => 'open bracket', ')' => 'close bracket', '-' => 'hyphen/minus', '$' => 'dollar', '=' => 'equals', '/' => 'forward slash', "\\" => 'backward slash', '|' => 'pipe', '!' => 'exclaimation', '"' => 'speech marks', '*' => 'asterisk', '£' => 'pound', '%' => 'percent', '^' => 'carrot', '&' => 'ampes and', '_' => 'underscore', '+' => 'plus', '{' => 'open curly bracket', '}' => 'close curly bracket', '[' => 'open square bracket', ']' => 'close square bracket', '~' => 'tilde', '#' => 'hash', '<' => 'less than', '>' => 'greater than', '@' => 'at', "'" => 'apostrophe', ':' => 'semi-colon', ';' => 'colon', ); while ( my ($punctuation, $count) = each(%wordHash) ) { $wordArray[my $i] = "$count\t$punctuation"; $i++; print ("$count\t$charnames{$punctuation}\n"); }
Enter filename to search for punctuation characters: ooperl.txt Use of uninitialized value in array element at punctuation.pl line 57. 2 hyphen/minus Use of uninitialized value in array element at punctuation.pl line 57. 1 close bracket Use of uninitialized value in array element at punctuation.pl line 57. 7 fullstop Use of uninitialized value in array element at punctuation.pl line 57. 7 comma Use of uninitialized value in array element at punctuation.pl line 57. 1 open bracket
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unitialized values - HELP!
by Fletch (Bishop) on Jan 11, 2007 at 14:44 UTC | |
|
Re: unitialized values - HELP!
by davorg (Chancellor) on Jan 11, 2007 at 14:48 UTC |