Front page | perl.perl5.porters |
Postings from February 2015
Re: [perl #123820] documentation error in perlrecharclass
Thread Previous
From:
demerphq
Date:
February 14, 2015 15:07
Subject:
Re: [perl #123820] documentation error in perlrecharclass
Message ID:
CANgJU+Wk-z1_wAQk23W6JKg0pFLZuE+w7R1thB5O_TBcbmYz1Q@mail.gmail.com
On 14 February 2015 at 22:29, James E Keenan via RT
<perlbug-followup@perl.org> wrote:
> On Fri Feb 13 21:13:32 2015, demerphq wrote:
>> On 14 February 2015 at 07:58, James E Keenan via RT
>> <perlbug-followup@perl.org> wrote:
>> > On Fri Feb 13 11:28:10 2015, saint.snit@gmail.com wrote:
>> >>
>> >> This is a bug report for perl from saint.snit@gmail.com,
>> >> generated with the help of perlbug 1.39 running under perl 5.18.2.
>> >>
>> >>
>> >> -----------------------------------------------------------------
>> >> The "perlrecharclass" documentation -- both that shipped with perl
>> >> 5.18.2
>> >> and that appearing at http://perldoc.perl.org/perlrecharclass.html
>> >> --
>> >> contains an error.
>> >>
>> >> It claims that the regular expression /[[]]/ "contains a character
>> >> class containing just ], and the character class is followed by a
>> >> ]".
>> >> This does not appear to be an accurate description of this regular
>> >> expression: the leading character class appears to contain just [.
>> >>
>> >
>> > I believe the analysis is correct.
>> >
>> > Here is the way the documentation appears in perl-5.10.1 (some
>> > whitespace trimmed):
>> >
>> > #####
>> > "[]" =~ /[[]]/ # Match, the pattern contains a character class
>> > # containing just ], and the character class is
>> > # followed by a ].
>> > #####
>> >
>>
>> It looks like this is a typo. it should say "containing just [".
>>
>>
>> > Let's stipulate that the final ']' is outside the character class.
>> > Then I ought to be able to rewrite the pattern to capture the
>> > contents of the character class, like so:
>> >
>> [snip]
>> > This suggests that the character class holds a single open-bracket
>> > '[' -- not a single close-bracket ']'. This in turn suggests that
>> > the documentation is indeed wrong.
>> >
>>
>> Interesting approach. For future reference the way I would analyse it
>> is as follows:
>>
>> $ perl -Mre=debug -e'/[[]]/'
[snip]
>> $ perl -Mre=Debug,COMPILE -e'/[[]]/'
[snip]
> I have patched pod/perlrecharclass.pod in commit 52f4d632547391b1db71d16e631dd023dcd6a9b0.
>
Cool, nice one.
> Yves, I was able to use your two diagnostics as far back as perl-5.10.1 and get similar results. The first diagnostic worked on perl-5.8.9; the second did not.
>
> #####
> $ perl -v | head -2 | tail -1
> This is perl, v5.8.9 built for x86_64-linux
>
> $ perl -Mre=Debug,COMPILE -e'/[[]]/'
> Unknown "re" subpragma 'Debug' (known ones are: 'debug', 'debugcolor', 'eval', 'taint') at -e line 0
> Unknown "re" subpragma 'COMPILE' (known ones are: 'debug', 'debugcolor', 'eval', 'taint') at -e line 0
Apologies, I should have said, I added Debug 'COMPILE' support in
5.10. We only needed to check the first one in 5.8.9. Which I guess
you did already. :-)
Yves
Thread Previous