develooper Front page | perl.perl5.porters | Postings from August 2021

Re: "use v5.36.0" should imply ASCII source

Thread Previous | Thread Next
Darren Duncan
August 7, 2021 06:51
Re: "use v5.36.0" should imply ASCII source
Message ID:
On 2021-08-06 11:45 p.m., Darren Duncan wrote:
> On 2021-08-06 5:01 p.m., Chris Prather wrote:
>>> On Aug 6, 2021, at 2:58 PM, Dan Book <> wrote:
>>> I don't think it's comparable. Comments are parsed by the perl interpreter, 
>>> but POD is not, except to find the end of the POD.
>> Additionally comments don’t as far as I know have a way to declare their 
>> encoding.
> Question:  Is there ever a real life scenario where a single source file is not 
> entirely the same encoding?  Can you reasonably have a single file containing 
> Perl code and POD where the Perl code is one character encoding and the POD is 
> another one? -- Darren Duncan

Or even putting aside the POD, is there any real scenario where a single file 
consisting of only Perl code is in multiple encodings at once?

If there is a "use utf8;" anywhere in a Perl file, would it not be reasonable to 
interpret that it is describing the entire file and not just the portion of the 
file below that statement?

Perhaps a reasonable design would be that if a file contains a UTF-8 declaration 
anywhere in it, the entire file is treated as such, both the part above and the 
part below that declaration.  And if multiple conflicting encoding declarations 
exist for the current file, that is an error.

Basically the encoding declaration can be something that is scanned for in 
advance of the regular parsing, or if done inline, encountering such would cause 
the parser to restart at the beginning if the declaration is different than what 
the parser was doing up to that point, effectively the whole file is affected by 
that declaration either way.

-- Darren Duncan

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About