CC: | knut−olav [...] hoven.ws |
Subject: | Misuse of length on array |
$ ack 'length\s*@'
lib/Weather/YR/Locationforecast.pm
29: push @forecasts, $forecast_ref unless length @forecasts;
length() only applies to scalars, so length @forecasts will evaluate @forecasts in scalar context,
which returns the number of elements. That number will be passed to length(), which will tell
you how many digits there are. Then ‘unless’ will see a positive number, so the push never
happens.
You just need:
push @forecasts, $forecast_ref unless @forecasts;