Orson schreef:

> what I need is construct a reg ex pattern and store
> in variable. I need to concatenate this from many other variables.
> Then I must use this variable to do a match. Something like this:
> while (<>)
> {
>     chomp;
>     my $pt = "\d" . "\s" . "\d";

This sets $pt to "dsd".


>     if ( /$pt/  )
>     {
>         print("Match also using variable\n");
>     }
>
>     if ( /\d\s\d/ )
>     {
>         print("Match not using variable\n");
>     }
> }
>
> The second match work if you give input  like "1987 1988", but I
> cannot get first match to work. I must be confusing perl with /$pt/

Read the documentation of qr().

  my $digit = q{\d};
  my $wsp   = q{\s};

  my $pt = qr{ $digit $wsp $digit }x;
  print $pt;


BTW, the "Match not using variable" regex matches only the part "7 1".
Is that what you want?

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to