in reply to Match Text with Single Quotes
G'day JLowstetter,
Welcome to the monastery.
I'd use qr for that. See perlop: Regexp Quote-Like Operators for details.
#!/usr/bin/env perl use strict; use warnings; my @lines = ("MyName='Custom'\n", "MyName!='Custom'\n"); my $re = qr{MyName='Custom'}; for my $line (@lines) { if ($line =~ $re) { print "MATCH: $line"; } else { print "NO MATCH: $line"; } }
Output:
MATCH: MyName='Custom' NO MATCH: MyName!='Custom'
-- Ken
|
|---|