in reply to handling printf 0 error

TIMTOWTDI, it also depends on exactly which of the values you're trying to print is undef - since I can't tell from your post I'm going to guess it's $A->{$key}->{$key2}, but if not, you will need to adjust the tests in the code examples below accordingly.

Solution 1: Disable those warnings altogether. Note that warnings can be useful in debugging, so this may not be the best unless you know what you're doing.

# ... foreach my $key2 (@aminos) { no warnings 'uninitialized'; printf OUT ("$forprint ", $A->{$key}->{$key2}); } # ...

Solution 2: Don't print at all if the value is not defined.

foreach my $key2 (@aminos) { printf OUT ("$forprint ", $A->{$key}->{$key2}) if defined $A->{$key}->{$key2}; }

Solution 3: Use the defined-or operator // to replace the undef value with the empty string. (Only available in Perl 5.10 and above)

foreach my $key2 (@aminos) { printf OUT ("$forprint ", $A->{$key}->{$key2} // ''); }

Solution 4: Skip the loop iteration entirely if the value is undefined. (similar idea to Solution 2)

foreach my $key2 (@aminos) { next unless defined $A->{$key}->{$key2}; printf OUT ("$forprint ", $A->{$key}->{$key2}); }

Replies are listed 'Best First'.
Re^2: handling printf 0 error
by madM (Beadle) on Apr 29, 2014 at 10:50 UTC
    thankyou! that really helped!