use strict; use warnings; use Data::Dumper; open(FH, "<", "./music.txt") or die $!; while(1) { print "Enter Either First or Last name of the artist -1 to quite>"; my $input =; chomp($input); if($input eq '-1') { exit; } if($input =~/^$/) { next; } &findArtist($input); } sub findArtist { my $userInput=shift; my $eachLine; my ($artistName,$cdTitle,$date,$price); my $flag=0; seek(FH, 0, 0); while($eachLine=) { ($artistName,$cdTitle,$date,$price)= split(/:/,$eachLine); if($artistName =~/$userInput/i){ print "Artist Name:$artistName\n","CD title:$cdTitle\n","Date:$date\n","Price:\$$price\n"; $flag=1; } } print "Artist not found\n" unless($flag); } close(FH);