#!/usr/bin/perl -w use strict; my @search; my $query = qr/perl/; open FILE, "file" or die "Error message here: $!"; while (<FILE>) { push @search, $_ if /$query/; } chomp @search; # If required close(FILE);
Also, the qr// operator is useful for pre-compliling a regular expression that will be used as a variable. See perlop for details.
--
John.
In reply to Re: Checking Arrays
by jmcnamara
in thread Checking Arrays
by kidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |