in reply to Parsing a date from comma-delimited file
split divides the string by the character to be split on and returns that many elements to the array. Thus resulting in an array of size 3 for each split per line.@lineData = split(/\,/, $line); should be... @lineData = split(/\//, $line); #parse 12/Mar/2004 the above results in: $lineData[0] = 12 $lineData[1] = Mar $lineData[2] = 2004 This is causing your comparison: if($lineData[18] == $date) to be wrong
Use eq for comparing strings instead of ==my $line_date = "$lineData[0]/$lineData[1]/$lineData[2]"; if($line_date eq $date){ print "equal\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Parsing a date from comma-delimited file
by playing18 (Initiate) on Apr 12, 2004 at 18:26 UTC |