Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nicomen opened this issue Oct 3, 2024 · 1 comment
Open

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

nicomen opened this issue Oct 3, 2024 · 1 comment
Labels

Comments

@nicomen
Copy link

nicomen commented Oct 3, 2024

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
Copy link
Contributor

xdg commented Oct 6, 2024

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

@xdg xdg added the bug label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants