Prabahar Mosas wrote:I have problem to assign a regular expression into a variable. If any one know regarding this mail me as early as possible. If it is cannot give me alternative solution.
specimen coding
**************
$value = 2422; $reg = '/\d/';
if ($value =~ $reg) {
print "Correct Value;
} else {
print "Check the Value";
}
Hi, if i'm understanding you correctly, I think what you want to do should be coded like this:
$value = 2422; $reg = '\d';
if ($value =~ m/$reg/) {
print "Correct Value;
} else {
print "Check the Value";
}
Or like this:
my $reg = qr/\d/;
if ($value =~ $reg) {However, I for one guess that what the OP *really* wants to do is something like this:
my $reg = qr/^\d+$/;
But since he is short of time, he is probably too busy to explain to us what it is he wants to achieve. :)
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
