Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I am attempting to set the value of blank elements in an array to zero. How can I do this? The input looks like this:
Thurs,July,5,2012,123,456,789 Thurs,July,5,2012,123,456,789,Fri,July,6,2012
Here is my code
my $line; my ($dow,$mon,$day,$year,$num1,$num2,$num3,$dow2,$mon2,$day2,$year2) = + ""; foreach $line (@array){ ($dow,$mon,$day,$year,$num1,$num2,$num3,$dow2,$mon2,$day2,$year2) += split /[,]/, $line; print "$dow2\n";
I would like to be able to print $dow2 through $year2 but I am getting the error "Use of uninitialized value $dow2 in print..." What am I doing wrong here?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Set Array Columns to 0
by jethro (Monsignor) on Jul 05, 2012 at 16:41 UTC | |
by Anonymous Monk on Jul 05, 2012 at 21:18 UTC | |
by frozenwithjoy (Priest) on Jul 06, 2012 at 07:08 UTC | |
|
Re: Set Array Columns to 0
by toolic (Bishop) on Jul 05, 2012 at 16:33 UTC | |
|
Re: Set Array Columns to 0
by brx (Pilgrim) on Jul 05, 2012 at 16:41 UTC |