Greeting I have a program take in a file and lets you add stuff to it after I add some words to it i want to count all the words in the file... I am having trouble with that ...here is my code so far. I looked up stuff online but it doesnt seem to work.
#!usr/bin/perl
print "Opening file attempt\n";
open (FILE, "+<@ARGV") or die ("Unable to open file exiting\n");
print "Printing current data in file:\n";
print while (<FILE>);
print "\nType something to add to file, press Enter when done\n";
$moredata=<STDIN>;
print (FILE $moredata);
close(FILE) or die ("Can't close this?!!?!?\n");
print "Opening file attempt\n";
open (NFILE, "@ARGV") or die ("Unable to open file exiting\n");
@array = <NFILE>;
close(NFILE) or die ("Can't close this?!!?!?\n");
foreach $string (@array){
$blah=shift($string);
$blah=split(/\W+/);
$count+=blah;
print $count;
}
Any help would be very appreciated...