dr_joe has asked for the wisdom of the Perl Monks concerning the following question:
This is a script I wrote to select only the five-letter and six-letter words from a list of words.
#!/usr/bin/perl #trimwords.pl #This script selects only the five-letter and six-letter words from a +list of words use warnings; use strict; open FH1, "all_words.txt" or die $!; open (FH2, '>>trimmed_words.txt') or die $!; my @all_words = <FH1> ; my $word_size; while (@all_words){ my $word_size = length($_); unless ($word_size==5 or $word_size==6){ shift(@all_words); }} print FH2 @all_words
Use of uninitialized value in length at trimwords_3.pl line 16, <FH1> line 224714.
Any guidance will be much appreciated by this novice. The following information may be useful:
The input file (all_words.txt) is 224714 lines long
The output file (trimmed_words.txt) comes out as empty as my wallet
I am running perl, v5.8.8 built for x86_64-linux-thread-multi
Thanks,
dr_joe
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: stuck at "Use of uninitialized value in length at ..."
by toolic (Bishop) on Jun 04, 2009 at 16:52 UTC | |
|
Re: stuck at "Use of uninitialized value in length at ..."
by Sue D. Nymme (Monk) on Jun 04, 2009 at 16:58 UTC | |
by ikegami (Patriarch) on Jun 04, 2009 at 17:03 UTC | |
|
Re: stuck at "Use of uninitialized value in length at ..."
by johngg (Canon) on Jun 04, 2009 at 17:53 UTC | |
|
Re: stuck at "Use of uninitialized value in length at ..."
by scorpio17 (Canon) on Jun 04, 2009 at 17:08 UTC | |
|
Re: stuck at "Use of uninitialized value in length at ..."
by Marshall (Canon) on Jun 04, 2009 at 17:03 UTC | |
|
Re: stuck at "Use of uninitialized value in length at ..."
by dr_joe (Initiate) on Jun 04, 2009 at 22:42 UTC | |
|
Re: stuck at "Use of uninitialized value in length at ..."
by mje (Curate) on Jun 04, 2009 at 16:51 UTC |