#!/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"); #### The word and occurred in Line 1 as the 7th word The word and occurred in Line 1 as the 11th word