in reply to Re: Re: Why doesn't % interpolate?
in thread Why doesn't % interpolate?

Given that "${s}" is the same as "$s" and "@{a}" is the same as "@a", then yes. It would mean that "%{f}" is the same as "%f", which would break a lot of code, even without considering printf formats.

Abigail

Replies are listed 'Best First'.
Re: Re: Why doesn't % interpolate?
by Anonymous Monk on Apr 19, 2003 at 21:18 UTC

    I'm not sure that follows. "is the same" for "${s}" & "@{a}" doesn't have to translate into "has to be the same" for "%{h}" does it? Perl has plenty on non-orthoganalities already.

    The "sigil{bareword}" syntax is specifically intended to disambiguate those cases where "sigil\w+" would be mis-interpreted

    my $a = $year < 1999 ? 'pre-' :'post-'; print "In the context of ${a}millenium treatment of dates, $year becam +e...";

    Are there any other cases that would need special treatment if "%h" was designated as being equivalent to "@{[ %h ]}" except when used with the format strings for (s)printf where it would be necessary to disambiguate it by using "%s %3d %{h}"? I can't think of any, can you?

      I'd say that 15 years of programming in Perl must have given us tons of code that uses %h, and expect it not to be interpolated as a hash. Suddenly changing the meaning of how strings are parsed would break that code.

      And it's not just printf formats that use lots of % characters. URIs use % to escape characters as well.

      But why make such a fuss? Why argue to break tons of programs just to save a few characters of typing for a not so very useful feature? The difference between "%{hash}" and "@{[%hash]}" is a whopping three characters.

      Abigail

        It was more a case of wondering why it wasn't done that way, rather than arguing for it's inclusion.

        Your point is made and well taken.