Hi people,

        I need to match string against regular expressions that are only
known at run-time. I'm having problems doing it so I made a small test
script like the following :

#!/net/tcmvega35/data1/automation/perl/bin/perl -w

use strict;
die "test.pl [string] [regex]" unless $#ARGV == 1;

if ($ARGV[0] =~ $ARGV[1])
{
        print "$ARGV[0] matches $ARGV[1]\n";
}
else
{
        print "$ARGV[0] does not match $ARGV[1]\n";
}

On the command lines, the following happend

allo al         => match
allo /al/               => no match (should match, no ?)
allo lo$                => match
allo ^al                => match
allo ^ao$               => no match (should match, no ?)

Questions :

        - Why don't I need the regular expression delimiters (/), is it
implicit when using
variables ?
        - If I don't add them (/), will it still work for all cases ?
        - Why doesn't the last case work ?

Thanks !

-Robin

Reply via email to