#!/usr/bin/perl
#
# If called with arguments (e.g. perl 11.pl ape monkey), then the arguments
# are stored in the array @ARGV; $ARGV[0] is ape and $ARGV[1] is monkey etc.
# 
# Write a script which accepts one argument and counts only those lines with 
# that string, AND puts those occurrences in parentheses.
# 
#
$" = "001";
$file = <~/doc/perl/leeds/electricity.txt>;		# Name of the file
open(INFO, $file);					# Open the file
$lines = <INFO>;					# Read it into a variable
while ($lines = <INFO>)
{
	if ($lines =~ $ARGV[0])				# if $lines matches $ARGV
	{
		$ARGV[0] =~ s/$ARGV[0]/\($ARGV[0]\)/g;	# THIS IS THE LINE
		print ($", $lines);
		++$";					# increment by 1
	}
	else
	{
		print $lines;
	}
}
close(INFO);						# Close the filose

