in reply to Testing if a .txt file contains any data
#!perl use warnings; use strict; my $wordlist = 'wordlist.txt'; open (LIST, $wordlist) or die "\n Cannot open $wordlist: $!\n"; my @listofwords; while (<LIST>) { chomp; push @listofwords, $_; } print "There are " . scalar(@listofwords) . " words in $wordlist\n"; if (@listofwords eq 0) { print "\n$wordlist contains nothing! \n"; exit 0 } else { print "\n$wordlist is loaded! \n"}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing if a .txt file contains any data
by locked_user sundialsvc4 (Abbot) on Jan 30, 2015 at 15:08 UTC |