Consider this code:
And what it outputs:#!/usr/local/bin/perl -w use strict; my $last = ""; my $first = ""; my $middle = ""; ( $last, $first ) = split /,/ , 'thumb,tom' ; print "last:($last) first($first) middle($middle)\n"; ( $first, $middle ) = split / / , $first ; print "last:($last) first($first) middle($middle)\n";
gonzo:/export/home/fredk/: ./bar.pl last:(thumb) first(tom) middle() Use of uninitialized value at ./bar.pl line 11. last:(thumb) first(tom) middle()
Does it make sense that warnings would complain about $middle not being initialized? In my case (the above is simplified) there are some records where there is <NULL> for $middle and others where $middle is defined. So when I print $middle and it is <NULL>, that's WIM (What I Mean).
Suggested work arounds?
-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday
In reply to Complaints from Warnings about uninitialized var by freddo411
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |