In this case, you (now) know that missing or undefined values (for the format string) are the cause of the warnings. Then, why not mute them for the relevant code for there is nothing else to "[miss] out on"?

... { no warnings 'uninitialized'; printf $format , @values; } ...

Since missing values do not matter, both Not_a_Number's and Grandfather's suggestion will work equally.

In case one would need to show the values under proper column headings, then you would need to fill in the missing or undefined values with substitute values (empty string, 0, -, N/A, /, etc). That may also call for the data to be properly formatted such that missing values are represented by their absence.

use strict; use warnings; my $title = " A B C D\n"; my $format = "%2d %2d %2d %2d\n"; print $title; printf $format , @{ $_ } for fetch_data(); sub fetch_data { my @data; while ( my $line = <DATA> ) { next if $line =~ m/^\s*#/ or $line =~ m/^\s*$/ ; push @data , [ map get_standin( $_ ), split /;/ , $line , 4 ]; } return @data; } sub get_standin { my ( $in ) = @_; my $standin = 0; return $standin unless defined $in; for ( $in ) { s/^\s+//; s/\s+$//; } return length $in ? $in : $standin; } __DATA__ # Data (say 2 digit numbers at most, or missing). 1; 2 ; 3; 5 9;97; ;0 ; 6 ; 8 ; ;;; 76

In reply to Re^3: How to avoid "Use of uninitialized value" with printf? by Anonymous Monk
in thread How to avoid "Use of uninitialized value" with printf? by bobdabuilda

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.