in reply to Getting regexp from Regexp references

(?-xism:^foo\.c$)
That is a perfectly valid regexp. The (?- allows one to specifiy regexp option inside the regexp pattern itself.

In addition to build your alternation there is no need to extract the original regexp, since you can quite safely interpolate Regexp objects into patterns:

my (@a) = (qr/^foo\.c$/, qr/^bar\.c$/, ); /$a[0]|$a[1]/; #or my $re = join("|", @a); /$re/;

--
integral, resident of freenode's #perl

Replies are listed 'Best First'.
Re: Re: Getting regexp from Regexp references
by bart (Canon) on Jan 28, 2003 at 20:36 UTC
    (?-xism:^foo\.c$)
    That is a perfectly valid regexp. The (?- allows one to specifiy regexp option inside the regexp pattern itself.
    Actually, it's "(?OPT-NOPT:PAT)", including the colon, which is a variation on the old familiar theme of "(?:PAT)". The hyphen and following negated options are optional.

    I'll give a somewhat more detailed example:

    qr/^foo.*\.c$/si
    as a string is
    (?si-xm:^foo.*\.c$)
    Thus: the enabled options come right after the question mark, disabled options come after that, between a hyphen and the colon.

    These are the only four options that can actually be used in this manner. Thus: the list of options is complete.

Re: Re: Getting regexp from Regexp references
by steves (Curate) on Jan 28, 2003 at 20:32 UTC

    Sometimes the obvious escapes me. Thanks. 8-)