in reply to about "say" function

The say function is not imported into the main namespace (Packages) by default. The shortest chain to importing it is via the feature pragma: use feature 'say';. say was implemented in Perl v5.10, but if it was imported by default, there would be the risk of backward compatibility problems and spurious warnings for perfectly fine old code. Alternatively, you can use say without importing it by giving the full package: CORE::say();.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: about "say" function
by lightoverhead (Pilgrim) on Aug 12, 2014 at 17:18 UTC

    kennethk

    Thank you for your prompt response. Actually, I have been wondering why "say" was not imported be default if this is a better feature and upgrade. Similar situations for smart comparision operators...

      For backwards compatibility with program/modules that have a sub/method called say.

      You do not need to enable a feature to use the smart match operator. You do for given and when, though, for the same reason as say.

        You're kidding right? Why can't those program modules what have a sub/method called say simply rename it? I doubt that every new function that has been introduced worried about possible name conclusions of functions in the past. Why is this different?