in reply to Regex from string

You need qr here and escape right paranthesis. Also have a look at perlre.

my $line = "root (hd1,1)"; my $match = qr/root \(hd[0-9],[0-9]\)/; if ($line =~ m/$match/is) { print "match 1 found \n"; }

updated: changed qw to qr. Zaxo++ Thanks.

Prasad

Replies are listed 'Best First'.
Re^2: Regex from string
by Zaxo (Archbishop) on May 31, 2006 at 10:39 UTC

    No. The qw operator returns a list, splitting on whitespace. That will place only the last element of the list, \(hd[0-9],[0-9]\)), in $match.

    After Compline,
    Zaxo