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
In reply to stuck at "Use of uninitialized value in length at ..." by dr_joe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |