#!/usr/bin/perl

use strict;
use warnings;
use File::Spec;

######################################################################
# ==========ENTER HERE============

my $regex		=	'q[^u]';

my $filename	=	"big_english.txt";
# my $filename	=	"ecoli.txt";

######################################################################
######################################################################
#
# DO NOT CHANGE THE PERL BELOW THIS POINT!

#-----------------------------------------------
# hold the regEx

# hold each of the words one at a time
my $nextWord;

# keep track of the number of words that match
my $nMatches = 0;
# ------------------------------------------------


# MacOS: If you are using TextWrangler, uncomment the next two lines
#my @path	= File::Spec->splitdir( File::Spec->rel2abs($0) );
#$filename	= File::Spec->catfile( @path[0 .. $#path - 1], $filename );

# open the file of words or motif
open(my $fh, '<', $filename) or die $!;

# loop thru the words in the file one a time
# each time checking to see if the regex matches
while (my $nextWord = <$fh>)  {
	chomp($nextWord);						# remove the newline
	
	if ( $nextWord =~ m/$regex/i )  {		# does this next word match the regEx? 
		$nMatches++;						# increment the match count
		print "($nMatches) $nextWord\n";	# print the result
	} # end if
	
} # end while

if ($nMatches == 0)
{
	print "No matches were found.\n\n";
}
