probably what you need is: $csv->print ($ip, \@record);.foreach my $ip (@ips) { $record[7]=$ip; $csv->print ($ips, \@record); #Error probably here (ips -> ip) }
If you were using use strict; use warnings; This should throw a compile error because the scalar $ips is not defined.
One thing to consider is avoiding variables that differ by just a single letter (ips vs ip). It is very easy to make a typing mistake and get confusing results. Also be aware that in Perl, a symbol like "ips" can be both an array variable @ips and a different scalar variable like $ips at the same time. Not everything that is possible is wise. Just for consideration, assuming you keep @ips as is:
Of course I have no context, but probably I would wind up changing @ips to something else: @local_ips, @network_ips, some name describing what kind of ips these are and keeping the simple $ip for the loop iterator name.foreach my $cur_ip (@ips) #or perhaps $this_ip or other name? { $record[7]=$cur_ip; $csv->print ($cur_ip, \@record); }
In reply to Re: Use of uninitialized value in subroutine entry
by Marshall
in thread Use of uninitialized value in subroutine entry
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |