in reply to keeping context in a loop

#!/usr/bin/perl use DBI;

You should also enable warnings and strictures to let Perl help you find mistakes.

#!/usr/bin/perl use warnings; use strict; use DBI;


open( FILE, "< $ARGV[0]" );

You should always verify that the file opened correctly.

open FILE, '<', $ARGV[ 0 ] or die "Cannot open '$ARGV[ 0 ]' $!";


while ( <FILE> ) { my $line = $_; chomp ($line); my @word = split / /, $line;

Or simply:

while ( my $line = <FILE> ) { chomp $line; my @word = split ' ', $line;


$count = 0; while ( $word[ $count ] ) { $word[ $count ] =~ tr/^[\-a-zA-Z]//; $word[ $count ] =~ s/\'/\\\'/g; $count++; }

That is usually written as:

for ( @word ) { tr/^[\-a-zA-Z]//; s/\'/\\\'/g; }

But tr/^[\-a-zA-Z]// doesn't do anything in this context so why is it there?



while ( $key = keys %uword ) {

That looks like you should be using each instead of keys as that produces an infinite loop.