#!/usr/bin/perl use strict; use warnings; my $recs = [ # short records for brevity {id => 1}, {id => 2}, {id => 3}, ]; my $rec; for $rec (@{$recs}){ # $rec is an alias... if ($rec->{id} == 1){ last; } } # ... which is now out of scope :-( print "$rec->{id}\n"; # Use of uninitialized value... # what I should have done ($rec) = grep {$_->{id} == 1} @{$recs}; print "$rec->{id}\n"; # 1