my $filename = "";
my $outputfile = "";
No real need to declare and initialize these here. You can do it when you get the input:
my $filename = <STDIN>;
chop ($filename);
Should use chomp, instead.
Then you make the computer read the whole file and do a bunch of matches that you completely ignore:
while (<INFILE>) #read the input file
{
while ( /(\w['\w-]*)/g ){ #if we have a "word";
}
Then a whole bunch of (re-)declarations and initializations, several of which were pointless, then some attempts to match on $_, but none of them happen because it's empty now.
The main problem is that you haven't wrapped your file-reading loop around the code that's supposed to be doing the work. Apart from that, you've made some sub-optimal decisions about what to use: the foreach's should probably be whiles, and the patterns should be qr//'d instead of double-quoted. |