$firstfewletters = param("SEARCH"); #a text box elsewhere if ($firstfewletters) { #checks that $firstfewletters has value ***start table here*** foreach $card (@stock) { #for every card in stock... if ($card =~ m/^$firstfewletters/) { # ...if that card's first few letters match # $firstfewletters ***printing each table element here*** } } ***end table here*** } else { print "Please enter the first few letters of the card's name, or enter a single letter to view just the cards beginning with that letter in our singles collection."; }