#!perl -w use strict; print "Author to search for:"; my $search = ; chomp($search); my $totalprice = 0; my $found = 0; my @info = (); my ($title, $autor, $genre, $price); open (INPUT, "books.txt") or die "Error: $!"; # always check for errors while (){ chomp $_; ($title, $autor, $genre, $price) = split (/:/,$_); if ($search eq $autor) { # eq for stringcompare, == for numerical $totalprice += $price; push (@info, [ $title, $genre, $price]); $found++; } } print "$found books by $autor were found...\n"; print "They are:\n"; print "\tBook Title\t\t\tGenre\tPrice"; foreach my $info (@info){ print join("\t", @$info), "\n"; } print "\tTotal price of these books by $search is $totalprice"; close INPUT;