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

[doc] paragraph mode discards any number of newlines at the beginning of the file #18352

Closed
learnbyexample opened this issue Nov 23, 2020 · 4 comments · Fixed by #18361
Closed

Comments

@learnbyexample
Copy link

Where

https://perldoc.perl.org/perlvar#$/

Description

The document says:

When $/ is set to "" and the entire file is read in with that setting, any sequence of consecutive newlines "\n\n" at the beginning of the file is discarded.

On testing, I find that a single newline at the beginning of the file is also discarded:

$ s='\na\nb\n\n12\n34\n\nhi'

$ printf '%b' "$s" | perl -00 -lnE 'say if $. == 1'
a
b

I don't think this is a bug, as this behavior is seen with awk too:

$ printf '%b' "$s" | awk -v RS= 'NR==1'
a
b
@khwilliamson
Copy link
Contributor

Taking a legalistic view, a single \n can be construed as "any sequence of newlines". But what would you like it to say instead?

@learnbyexample
Copy link
Author

any sequence of newlines

That would be fine with me, currently it says

any sequence of consecutive newlines "\n\n"

@Grinnz
Copy link
Contributor

Grinnz commented Nov 27, 2020

Perhaps it would be clearest to say: "any sequence of one or more consecutive newlines"

@khwilliamson
Copy link
Contributor

khwilliamson commented Nov 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants