#!/usr/bin/perl $wordcount=0; $line = ; chomp($line); WHILE ($line ne "") { @array=split(/ /, $line); for ($i=1; $i<@array; i++) { print $i; } if ( @array =~ /^and/gi) { $wordcount += @array; } $line= ; } print("Total number of works is $wordcount \n");