William wrote: > Hello, what is the syntax for having constant in regular expression ? Such as > > use constant (NL => '\n');
You know this will create NL as a two-character string - backslash and 'N' - right? You need double quotes if you want the "\n" control character. > #check if there is newline in the text > my $txt = "foo \n bar"; > if($txt =~ m/ > # ??? > /x) > { > > } Constants are actually subroutines, and a regular expression behaves the same as a double-quoted string for interpolation, so you can use any of the techniques described in perldoc "expand function calls" in this case it's probably easier to assign the regular expression to a scalar variable first. my $newline = qr/\n/; if ($text =~ $newline) { : } HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/