in reply to Re^4: Composing regex's dynamically
in thread Composing regex's dynamically

See perlop on qr:

It (the result of qr) magically differs from a string containing the same characters: ref(qr/x/) returns "Regexp", even though dereferencing the result returns undef.

Basically, the difference between strings and regular expression objects is very, very thin from a user point of view.

Replies are listed 'Best First'.
Re^6: Composing regex's dynamically
by John M. Dlugosz (Monsignor) on Apr 28, 2011 at 08:15 UTC
    I read that sentence, but didn't take-away the same thing.

    But a string containing the same characters would not have the same meaning! ... Hmm, playing around a little, I see: "a string" value is not the same as a string literal. Once it's in a string, the backslashes in particular are already understood.

    So, assuming the line in the docs is not written with the precision of an ISO standard, the intent is that the stringified regexp should contain whatever is necessary to reproduce the same meaning if compiled again?

      You can print out a regex:

      my $re = qr/foo/; print "$re";

      The stringified regex can be readily used as a regular expression again.

        That's what I'm seeing.