Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^6: Data::Dumper output

by hippo (Bishop)
on May 08, 2021 at 22:45 UTC ( [id://11132286]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Data::Dumper output
in thread Data::Dumper output

say outputs a trailing newline unless the arguments already contain a trailing newline.

Are you sure about that? The documentation makes no mention of such a condition and this example suggests that it is not the case:

$ cat say.pl #!/usr/bin/env perl use strict; use warnings; use feature 'say'; my $x = "foo\n"; my $y = 'bar'; say $x; say $y; $ ./say.pl foo bar $

🦛

Replies are listed 'Best First'.
Re^7: Data::Dumper output
by afoken (Chancellor) on May 09, 2021 at 09:51 UTC
    say outputs a trailing newline unless the arguments already contain a trailing newline.

    Are you sure about that? The documentation makes no mention of such a condition and this example suggests that it is not the case:

    D'oh! Of course, you are right, say simply appends a newline, and that's also what's written in the documentation.

    The "add a newline unless there is already one" is my mental model of say, and my code never proved me wrong - because I never called it with a string already containing a trailing newline. And to make things worse, I even linked to the documentation in Re^5: Data::Dumper output. I wonder why my mental model of say is wrong. A blame on perlfunc states that the documentation hasn't changed for two years, and has no relevant changes since say was introduced.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132286]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (None)
    As of 2024-04-25 01:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found