in reply to Re^4: nested <FILE> read returns undefined?
in thread nested <FILE> read returns undefined?
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.{ # 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)
|
|---|