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

Re: Array of Hashes

by 1nickt (Abbot)
on Feb 07, 2019 at 15:02 UTC ( #1229554=note: print w/replies, xml ) Need Help??

in reply to Array of Hashes

Hi, you are debugging with:

$field1 = $row->{field1}; $field2 = $row->{field2}; $field3 = $row->{f +ield3}; print "Row id is $field1, field 2 is $field2, field 3 is $field3\n";

You might like sprintf, you can skip all that assigning to temporary variables just to debug an interpolated string:

print sprintf "Row id is %s, field 2 is %s, field 3 is %s\n", @{$row}{ +qw/field1 field2 field3/};

Hope this helps!

The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Array of Hashes
by GrandFather (Sage) on Feb 07, 2019 at 19:42 UTC

    Why print sprintf ... instead of printf ...?

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      Hi Grandfather, because I would use

      but didn't want to introduce that change in my comment.

      And because usually I am doing

      $log->debug(sprintf 'format', @values)
      or even
      $msg = sprintf 'format', @values; $DEBUG && say $msg && $log->debug($msg);

      Basically, I've never used printf alone in the last 20 years, because it does not meet my needs.

      The way forward always starts with a minimal test.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2020-09-30 09:48 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (160 votes). Check out past polls.