title: How can I render undefined values from printf in Perl?
body: <p>I'm looking for an elegant way to denote undefined values in situations where formatted numbers usually render. I'll work up a small example. For starters, you of course can't use this:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  for my $s (1, 1.2, undef, 1.3) {
      printf "%5.2f\n", $s;
  }
  </code></pre>
  
  <p>...because the 'use warnings' nails you with 'Use of uninitialized value...' on the third iteration. So the next step is something like this:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  for my $s (1, 1.2, undef, 1.3) {
      printf "%5.2f\n", $s//0;
  }
  </code></pre>
  
  <p>And, boy, do I like the new 5.10 '//' operator, by the way. But that's really not what I want, either, because the value of $s isn't zero, it's undefined. What I really want is something like this:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  for my $s (1, 1.2, undef, 1.3) {
      printf "%5.2f\n", $s//q();
  }
  </code></pre>
  
  <p>...but I can't because this generates the "Argument "" isn't numeric..." problem on the third value.</p>
  
  <p>This brings me to the doorstep of my question. I can of course write code that checks every number I emit for defined-ness, and that creates a whole different non-%f-based printf format string, but, well, ...yuck.</p>
  
  <p>Has anyone defined a nice way to deal with this type of requirement?</p>