Unitialized variable

Mike Maxwell mmaxwell at umd.edu
Wed Sep 27 16:57:23 CEST 2023


On 9/27/2023 12:30 AM, Norbert Preining wrote:
> Also, the line referenced is
> 	print $STATUS_FH "@_\n";
> which does not reference $_[4] at all ... this is very absurd.

I'm no Perl programmer, but doesn't this $_[4] mean the 5th arg in the 
array @_ ?  (5th, since the array elements are numbered from 0)  The 
full code for this function is
-----------
sub log_to_status {
   if ($STATUS_FH) {
     print $STATUS_FH "@_\n";
   }
}
-----------

so $_[4] would be the 5th element in the function's argument array.  The 
function log_to_status is called several times as follows:
-----------
log_to_status("DISABLED", $fmt, $eng, $what, $whatarg);
-----------

So it sounds like the error msg is saying $whatarg is uninstantiated. 
This variable appears to come from here:
------------
sub callback_build_formats {
   my ($what, $whatarg) = @_;
   ...
------------

This callback_build_formats function is usually called with two args, 
but sometimes with just one, e.g.
-----------
} elsif ($opts{'missing'}) {
     return callback_build_formats('missing');

   } elsif ($opts{'all'}) {
     return callback_build_formats('all');
----------

Like I say, I'm not a Perl programmer, but what happens if you call a 
function with one arg, then inside the function you break the array of 
args into two args--will the second arg be uninstantiated?  Which is 
what the error msg is reporting.

     Mike Maxwell


More information about the tex-live mailing list.