[dancer-users] D1 => D2 from_yaml has changed

Gabor Szabo gabor at szabgab.com
Thu Dec 11 09:50:51 GMT 2014


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
ps. Now that I saw this code, I am going to convert it to Path::Tiny, but I
think the reason I have not used it earlier was that the 'path' function of
that module and the 'path' function of Dancer would clash.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20141211/5ba9fa04/attachment.html>


More information about the dancer-users mailing list