Clearly, one of the values ββin %{ $args{car_models} } not a hash reference. That is, the data structure does not contain what you think. Thus, you can either correct the data structure or change your code in accordance with the data structure. Since you did not provide a data structure, I cannot comment on this.
You can use ref to find out if $_ a hash reference before trying to access a member.
if ( ref eq 'HASH' and exists $_->{year} ) { push(@not_sorted_models, UnixDate($_->{year},"%o")); }
Based on your comment and my powers of ESP, I assume these values ββare timestamps. So, I assume you are trying to find the year from the timestamp value (the number of seconds from an era). In this case, you probably want localtime or gmtime :
my $year = 1900 + (localtime)[5];
C: \ Temp> perl -e "print 1900 + (localtime (1249998666)) [5]"
2009
In addition, specific information about what your data structure should contain is my best guess.
Sinan ΓnΓΌr
source share