jjohhn has asked for the wisdom of the Perl Monks concerning the following question:
The $line variable that is being split prints fineuse strict; # finds the words in $otherfile that are not in $wordfile; my $wordfile = shift; my $otherfile = shift; sub dict_line{ our %dict; my $line = shift; print $line; my @words = split $line; #print"@words"; foreach my $word (@words){ $dict{lc $word}++; #print "$word\n"; } } sub find_missing{ our %dict; my $line = shift; my @words = split $line; foreach my $word (@words){ print "$word\n"; my $word = lc shift; print "* $word\n" if !defined $dict{$word}; } } sub read_file{ my $file=shift; my $subref = shift || \&read_line; open (FILE, $file) || die "couldn't open $file $!"; while (my $line = <FILE>) { $subref->($line); } } read_file $wordfile, \&dict_line; read_file $otherfile, \&find_missing;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: uninitialized value in split
by dragonchild (Archbishop) on May 17, 2005 at 02:57 UTC | |
by jjohhn (Scribe) on May 17, 2005 at 03:07 UTC | |
by TheStudent (Scribe) on May 17, 2005 at 03:15 UTC | |
by jjohhn (Scribe) on May 17, 2005 at 03:22 UTC | |
|
Re: uninitialized value in split
by Skeeve (Parson) on May 17, 2005 at 10:14 UTC |