You have some strange things going on at the top of your file. Comments interspersed:
my $words_file = @ARGV;
# Evaluating an array in scalar context returns the length
# of the array. So if you are passing your script one filename,
# $words_file will equal '1', not the first argument from the
# command line. Pass it two filenames, and it will equal 2, etc.
# But that doesn't matter, because of another bug:
open (my $fh, ">", $words_file);
# Here you open the file for writing, but never use it.
# (You should also check for errors, or use autodie.)
my @words;
while (<>) {
push(@words, $_);
}
# Which turns out also not to matter, because you then use
# the <> operator, which reads from the files in @ARGV
# automagically. So lines 4 & 5 (the first two I quoted),
# though broken, don't affect anything else, and could be
# discarded.
Aaron B.
Available for small or large Perl jobs; see my home node.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|