CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: uninitialized value - help please. : Edit Log



netmonky
Novice

Feb 18, 2011, 3:37 AM


Views: 2165
uninitialized value - help please.

Hi all,



I have some data that looks like

name,address,phone,,friend,1,2,3,4

name,address,phone,8,friend,1,2,3,4

I am splitting the values and assigning them to variables in a while loop.

while (<INFILE>) {
my @filelist = split(/,/,$_);
my $name = $filelist[0];
my $add = $filelist[1];
my $phone = $filelist[2];
my $num = $filelist[3]; <<--Use of uninitialized value $filelist[3]
my $friend = $filelist[8];



I keep seeing Use of uninitialized value $filelist[3] when nothing is in field 3 of the array. I can turn warning off and all is good :-) -- but I would like to know the correct way of doing this please.



Thanks in advance!

Mark


(This post was edited by netmonky on Feb 18, 2011, 3:41 AM)


Edit Log:
Post edited by netmonky (Novice) on Feb 18, 2011, 3:41 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives