I want to search for coulours and have the whole block as a result. thankscolours red blue yellow
#!/usr/local/bin/perl use strict; my $file = 'thesaurus'; # Name the fil +e open(INFO,$file) || die "Cannot open file"; # open the fil +e or say can't open file # Read it in +to an array print " what are you looking for? "; $a = <STDIN>; chomp $a; # get rid of a + new line while (<INFO>){ if($file eq "\n"){ last; } my @matches = grep {/$a/i} <INFO>; # find all +the matches print "The following matches were found: @matches\n"; # print th +e matches }
In reply to pattern matching by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |