in reply to /foo${re}bar/

{}'s are separators. They are used such that Perl knows where the variable name finishes:

$x = "abc"; $xghi = "def"; print "${x}ghi\n"; # abcghi print "$xghi\n"; # def

Replies are listed 'Best First'.
Re: Re: /foo${re}bar/
by eweaverp (Scribe) on Jul 27, 2003 at 04:19 UTC

    Why not /foo{$re}bar/? Just that {} already is used for repetition, and a number would get interpolated?

    Which usage came first in Perl-time?

      er, no. ${foo} has been the standard way to disambiguate variables for a long time now and was independent of regex. Mostly used for strings, aside from this as in: print "${Foo}bar" and similar, also used for references, so called "soft" refs in the form of ${"foo"} and hard refs in the form of $x=\$foo; ${$x} Also works with the various other sigils, $%@.