in reply to Calculate jackknife error from of each column of a multi-column file

Hello, pyari_billi and welcome to the monastery.

The warning is alerting you to the fact that by the time your code gets to line 19 there is no value in $n[$j] because the only thing you have put in @n is 0. You must store a value in a variable (scalar/array/hash) before you can extract it.

But I want to set the size of @n dynamically depending on the size of the data file.

You can either do that as you go along (arrays can be expanded or shrunk dynamically in perl) or you can perform 2 passes of the file. The former is usually preferable. Something like:

foreach my $j ($col_start .. $#column) { $n[$j] //= 1; # Choose whatever suitable value you want here - it +could even be an expression $x[$n[$j]][$j] = $column[$j]; # ... etc.

The value you choose to set will depend on your algorithm, of course. Perhaps you want to use $.? Anyway, I hope this makes the problem more clear to you.


🦛