freddo411 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Complaints from Warnings about uninitialized var
by Fletch (Bishop) on Mar 10, 2005 at 00:56 UTC | |
|
Re: Complaints from Warnings about uninitialized var
by Tanktalus (Canon) on Mar 10, 2005 at 01:00 UTC | |
|
Re: Complaints from Warnings about uninitialized var
by mifflin (Curate) on Mar 10, 2005 at 00:56 UTC | |
|
Re: Complaints from Warnings about uninitialized var
by jhourcle (Prior) on Mar 10, 2005 at 03:21 UTC |