in reply to Matching strings differing by a number of periods
How about storing each line in a temporary variable, removing periods from that and then matching against the resulting string? e.g.
@matches=( qr/match1/, qr/match2/, ...); open ($file,"<","/path/to/file") or die ("Horribly"); while (<$file>) { $temp=$_; $temp=~s/\.//g; for my $match (@matches) { if ($temp =~m/$match/) { do_something(); } } }
If you're only going to match against one value you're probably better off adjusting that value (e.g.
join(".?",(split(//,$match)))), but if you have multiple matches(and possibly multiple ignorable characters) the first suggestion should work well for you.
|
|---|