J
Jürgen Exner
ela said:I wish pasting the content won't make any character loss but my program and
data is like the following:
You can see data1 is simply the substring of data2 and therefore I pass the
file containing data2 as $file1 and then the longer one as $file1 to my perl
program. $file1 content will be split by the delimiter tab and to check
against whether it contains any pattern that exist in data1.
Is your data1 a regular expression? If not then there is no need to
wield the big RE stick: as simple call of index() will tell you if it is
a substring of some other string.
If you insist on using m//, then you need to escape all RE
meta-characters in your pattern ...
[...]
my $pattern = $aref1->[0];
$pattern = quotemeta $pattern ;
$aref2 = quotemeta $aref2;
.... which apparently you are doing here.
if ( $pattern !~ /$aref2/ ) {
But why are you calling the string "pattern" and the regular expression
pattern "aref". Are you trying to confuse your readers?
And why on earth are you doing a quotemeta on your string? Now your
string of maybe
(Hello-all)
has become
\(Hello\-all\)
and obviously that will not be matched by e.g. the quotemeta'ed
o\-a
which would be searching for a literal o, followed by a dash, followed
by an a.
jue