dagolden / Path-Tiny

File path utility
41 stars 58 forks source link

$/ affects Path::Tiny->lines #297

Open nicomen opened 1 month ago

nicomen commented 1 month ago

It seems undefining $/ affects the behaviour of the lines method.

$ echo -e "a\nb\n" > foo; perl -MPath::Tiny -wlE 'local $/; print scalar path("foo")->lines'
1

Is this wanted behaviour? I just spent some time debugging an issue with a call to lines deep into code and further out $/ was localized.

Personally I use stuff like Path::Tiny to avoid "clever" globals like $/ having any impact.

If this is intended behaviour, should it be possible to tell lines to ignore $/ or set a custom line-ending character?

If not, should one always define $/ to wanted value before using lines?

And I guess no matter what, the current behaviour of respecting $/ should perhaps be clearly documented.

xdg commented 1 month ago

I think you're right that $/ should be ignored.