Skip to content

perlfunc: Revise 'print' entry#24370

Open
khwilliamson wants to merge 1 commit intoPerl:bleadfrom
khwilliamson:perlfunc_print
Open

perlfunc: Revise 'print' entry#24370
khwilliamson wants to merge 1 commit intoPerl:bleadfrom
khwilliamson:perlfunc_print

Conversation

@khwilliamson
Copy link
Copy Markdown
Contributor

This fixes #18861

This rewords the 'print' entry as asked for by this ticket and its comments.

  • This set of changes does not require a perldelta entry.

This fixes Perl#18861

This rewords the 'print' entry as asked for by this ticket and its
comments.
@khwilliamson
Copy link
Copy Markdown
Contributor Author

This is going to fail porting tests, because I did something unexpected in the synopsis. But I thought I'd get people's comments on the actual content of it.

@khwilliamson khwilliamson requested review from Grinnz and leonerd April 15, 2026 15:44
@Grinnz
Copy link
Copy Markdown
Contributor

Grinnz commented Apr 15, 2026

I don't think you referenced the right issue

Comment thread pod/perlfunc.pod

We'll have more to say below about using braces for more complicated cases.

Without the braces, ambiguities are still possible. Consider
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even more ambiguous is when you print the return value of a function, like print foo; maybe useful to mention something like this as well.

Comment thread pod/perlfunc.pod
Comment on lines +6387 to +6388
C<FILEHANDLE> may be a bareword, in which case it must be associated
with a file, pipe, or descriptor. That association is implicit for
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"file, pipe, or descriptor" - I'm not sure what you mean by descriptor here in context. Also sockets, TTYs, and probably other writable devices that don't occur to me right now.

I think it could just be something like "... may be a bareword, which must be an open handle opened for output."

Comment thread pod/perlfunc.pod

C<FILEHANDLE> may be a bareword, in which case it must be associated
with a file, pipe, or descriptor. That association is implicit for
either of the barewords C<STDOUT> or C<STDERR>, or explicit by use of
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STDOUT, STDERR and ARGVOUT. But I don't think describing all the possible handles belongs here.

Comment thread pod/perlfunc.pod
the previous paragraph, or itself have been used in an C<open> or
C<sysopen> call, and not have been closed in the meantime.

C<FH_EXPRESSION> is an expression that evaluates to a scalar value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses globs:

$ perl -e 'print {*STDOUT} "Hello\n"'
Hello

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think the description of valid handles is overly prescriptive, eg. that the be a scalar variable .. itself have been used in C<open> or C<sysopen> call

Even adding socket, pipe, this sounds like you have to use the original variable, and that a copy isn't valid.

Similarly with barename

# FOO hasn't been passed to open, sysopen
$ perl -e '*FOO = *STDOUT; print FOO "Hello\n"'
Hello

Perhaps this should refer to perldata/Typeglobs and Filehandles

@tonycoz
Copy link
Copy Markdown
Contributor

tonycoz commented Apr 15, 2026

I don't think you referenced the right issue

I suspect it's #18661

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants