{ # customize $/, but only inside this code block: local $/ = "----------\n"; while () { chomp; # this removes $/ from the end my ( $image, @attributes ) = split /\n/; $image = s/^image:\s+(.*)/\L($1)/; next unless ( exists $db->{$image} ); # do something with @attributes... } } # now $/ is back to normal # (updated to add chomp call)