RE: Matching a Scalar Variable
- From: cclarkson@xxxxxxxxxx (Charles K. Clarkson)
- Date: Tue, 29 Nov 2005 14:20:53 -0600
JupiterHost.Net <mailto:mlists@xxxxxxxxxxxxxxx> wrote:
: Thanks for catching my misstatement :)
Thanks for finally making one. :)
: #!/usr/bin/perl
:
: use strict;
: use warnings;
:
: open my $file1_fh, '<', 'file1' or die "file1 open failed: $!";
:
: open my $file2_fh, '<', 'file2' or die "file2 open failed: $!";
: my @match_list = <$file2_fh>;
: close $file2_fh;
:
: while(<$file1_fh>) {
: my $line = $_;
: chomp $line;
:
: for my $match_against (@match_list) {
: chomp $match_against;
: print "Got the string\n" if $line =~ m{$match_against}xms;
: }
: }
:
: close $file1_fh;
Yes, this is the option the OP chose in a message up thread
from here.
The only thing I would change is the repeated chomping of
the matches. On second thought I'll also complain about that
5-space initial indent. :)
open my $file2_fh, '<', 'file2' or die "file2 open failed: $!";
chomp( my @match_list = <$file2_fh> );
close $file2_fh;
.
.
.
for my $match_against (@match_list) {
print "Got the string\n" if $line =~ m{$match_against}xms;
}
Why the {}xms options on the regex? We aren't messing with $/,
so there shouldn't be any multi-line problems. Is it just a
precaution or is their some other reason?
Christmas*, perhaps? :)
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
* Christmas is sometimes referred to as "Xmas" in my country.
.
- Follow-Ups:
- Re: Matching a Scalar Variable
- From: JupiterHost.Net
- Re: Matching a Scalar Variable
- References:
- Re: Matching a Scalar Variable
- From: JupiterHost.Net
- Re: Matching a Scalar Variable
- Prev by Date: Re: the time a program runs
- Next by Date: Re: Matching a Scalar Variable
- Previous by thread: Re: Matching a Scalar Variable
- Next by thread: Re: Matching a Scalar Variable
- Index(es):
Relevant Pages
|
|