<div dir="ltr">







<p><span>I used to have this code:</span></p><p><span>sub </span><span>read_sites </span><span>{</span></p><p><span>    </span><span>open</span><span> </span><span>my</span><span> </span><span>$fh</span><span>, </span><span>'<encoding(UTF-8)'</span><span>, mymaven->{root} . </span><span>'/sites.yml'</span></p><p><span>        </span><span>or</span><span> </span><span>return</span><span> {};</span></p><p><span>    </span><span>my</span><span> </span><span>$yaml</span><span> = </span><span>do</span><span> { </span><span>local</span><span> </span><span>$/</span><span> = </span><span>undef</span><span>; <</span><span>$fh</span><span>> };</span></p><p><span>    from_yaml </span><span>$yaml</span><span>;</span></p><p>}</p><p><span>where sites.yml is this file: <a href="https://github.com/szabgab/perlmaven.com/blob/main/sites.yml" target="_blank">https://github.com/szabgab/perlmaven.com/blob/main/sites.yml</a></span></p><p><span>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.</span></p><p><span></span></p><p>=================</p><p><span>I see that in D1 from_yaml was this code:</span></p><p><span>YAML::Load(</span><span>$content</span><span>);</span></p><p>In D2 it is now this code:<br></p><p><span>YAML::Load(decode(</span><span>'UTF-8'</span><span>, </span><span>$content</span><span>));</span><br></p><p><br></p><p>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?</p><p>What was the recommended approach here for D1 and what is it for D2?</p><p>Gabor</p><div>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.</div><div></div>
</div>