http://www.perlmonks.org?node_id=405118


in reply to Re: Searching in an array of arrays
in thread Searching in an array of arrays

Hello zejames!
Thanks a lot for your reply. I do not understand your code fully, please bear with me. What
are the variables last_range and first_day used for, and what should their initial values be?

Also for this line,
my $range = $day->[1] - ($day->[1] % 5);
I get this error:
Operation `%': no method found,left argument in overloaded package XML +::XPath::Literal,right argument has no overloaded magic at C:\..\xmlr +ecord_parse.pl line 604.
Using sprintf removes the error, but I'm not sure whether this is correct(i.e. the control string "%f"):
my $range = sprintf("%f","$day->[1]") - (sprintf("% f","$day->[1]") % 5);
My array of arrays @data looks like this:
[ 1-1-2004 15.0 ], [ 2-1-2004 15.5 ], [ 3-1-2004 16.5 ], [ 4-1-2004 17.0 ], [ 5-1-2004 17.5 ], [ 6-1-2004 18.0 ], [ 7-1-2004 18.5 ], [ 8-1-2004 19.0 ], [ 9-1-2004 19.5 ], [ 10-1-2004 25.0 ], [ 11-1-2004 26.5 ], [ 12-1-2004 27.5 ], [ 13-1-2004 28.0 ], [ 14-1-2004 29.5 ], [ 15-1-2004 28.0 ], [ 16-1-2004 28.8 ],
So the resulting array of arrays I need to build should look like this:
1-1-2004 5-1-2004 mild 10-1-2004 14-1-2004 verywarm
The values of $range (printing inside the loop)I'm getting are:
15 15.5 15.5 15 15.5 15 15.5 15 15.5 25 25.5 25.5 25 25.5 25 25.8
This statements does not print anything:
print "$first_day $day->[0] ".$ranges{$range}."\n";
Please help, really need it!

Thanks,
perl_seeker:)