I used to have this code:
sub read_sites {
open my $fh, '<encoding(UTF-8)', mymaven->{root} . '/sites.yml'
or return {};
my $yaml = do { local $/ = undef; <$fh> };
from_yaml $yaml;
}
where sites.yml is this file: https://github.com/szabgab/perlmaven.com/blob/main/sites.yml
That worked well. Now it returns undef and does not evan complain about not being able to convert my yaml string to perl data structure.
=================
I see that in D1 from_yaml was this code:
YAML::Load($content);
In D2 it is now this code:
YAML::Load(decode('UTF-8', $content));
So I wonder, was I doing it all wrong earlier, but it worked because of the (mis)feature of Dancer? Should I refrain from using from_yaml at all for data I read in myself?
What was the recommended approach here for D1 and what is it for D2?
Gabor