$lookfor=; chop($lookfor); if ($lookfor =~ /year/i){ for $list_ref1 ( sort { $a->[0] cmp $b->[0] } @inventory ) { print "\t [ @$list_ref1 ],\n"; } } if ($lookfor =~ /make/i){ for $list_ref1 ( sort { $a->[1] cmp $b->[1] } @inventory ) { print "\t [ @$list_ref1 ],\n"; } }