in reply to Using regex with a variable

Hello Praveen Dharmaraj,

Please put <code> ... </code> tags around your code, to make it readable. See Markup in the Monastery.

You don’t say how and where the line should match. Please show the output you want to get, together with the value of the $ur variable.

When storing a regular expression in a variable, you should use Perl’s special qr operator, explained in perlop#Regexp Quote-Like Operators. For example:

my $reg1 = qr/=/i;

(No need to escape the = character here, BTW.) And you do use strict; and use warnings;, don’t you?

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,