On Thu, Apr 26, 2001 at 02:49:41PM +0100, Gary Stainburn wrote:
> Hi all,
>
> Using the following code:-
>
> 63 foreach (@fieldmap) {
> 64 my ($dbfield,$field)=(split(/:/))[0,$fieldno];
> 65 print "dbfield='$dbfield' field='$field'\n";
> 66 &addtext($dbfield,$fields{$field}) if ( $field ne '' && \
> $fields{$field});
> 67 }
>
> with the following data:-
>
> $_ from foreach is 'pickno:PICKNO::'
> $fieldno=2
>
> I get the following error message:-
<pick type="nit">ITYM "warning message".</pick> :-)
> Use of uninitialized value in concatenation (.) at ./import line 65
>
> When I added the following after line 64, I got printed out what I
> expected, and the error line number just went up one:-
>
> print "$_\n";
>
> If I remove the line, the error goes away so it is definitely
> complaining about the print statement, but it looks perfectly fine to
> me.
An explanation can be found in the 'fine print' of the documentation
for split():
If LIMIT is specified and positive, splits into no more than that
many fields (though it may split into fewer). If LIMIT is unspecified
or zero, trailing null fields are stripped (which potential users
of C<pop()> would do well to remember). If LIMIT is negative, it is
treated as if an arbitrarily large LIMIT had been specified.
So you're trying to print an undef value, thus the warning.
--
[W]hen the manager knows his boss will accept status reports without
panic or preeemption, he comes to give honest appraisals.
- F. Brooks, _The Mythical Man-Month_