Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
To continue to use \n, use a list with print ...

Yes. Although I'd use a separate line for clarity

print Dumper $data_structure; print "\n";

Just use say:

say Dumper $data_structure;

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

I just feel that is clearer and less prone to the sort of error I created.

I'm no Lisp guy, but using a few more brackets helps to avoid ambiguity and misunderstandings between humans and computers. If you call a function or method, add brackets around the argument list. That's what I do, with only very few exceptions - mostly stuff that is listed in perlfunc, but behaves more like a keyword or a C macro (__FILE__, __LINE__, __PACKAGE__, do, eval, package, use, require) than like a function.

I would have written ...

say Dumper($data_structure);

... in code for perl 5.10 and newer (i.e. with use v5.10 in the file), or ...

print Dumper($data_structure),"\n"; # or print Dumper($data_structure)."\n";

... in code for older perls.

Alexander

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

In reply to Re^5: Data::Dumper output by afoken
in thread Data::Dumper output by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-19 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found