in reply to Re^4: nested <FILE> read returns undefined?
in thread nested <FILE> read returns undefined?

I gather you have reached a solution based on the replies already posted, but just for the sake of TMTOWTDI, your data would make a nice case for customizing the INPUT_RECORD_SEPARATOR variable, $/, like so:
{ # customize $/, but only inside this code block: local $/ = "----------\n"; while (<FILE>) { 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)
Note that if you are using modules or reading from other files while doing things with the attributes within that block, the altered value of $/ will be in effect -- you may need to create more block boundaries to localize it again back to its original value.