http://qs1969.pair.com?node_id=11144154


in reply to Re^6: Capture a non-printable char and test what it is
in thread Capture a non-printable char and test what it is

G'day Alexander,

My intention was to show the variety of alternatives available. I would never expect the "... && ... && ..." to be used in a real program.

"# that's not perl: && ord($key) == 0o33"

Actually it is; however, it's very new. See "perl5340delta: New octal syntax 0oddddd".

I have Perl v5.34.0 installed. I checked my code with "perl -e 'use strict; use warnings; ...'" which would normally pick up things introduced since v5.8 (e.g. say). It's good to know that 0o33 passed on my installation without including a "use 5.034;" statement; I'll keep an eye on that in other code. Thanks for spotting this.

— Ken

Replies are listed 'Best First'.
Re^8: Capture a non-printable char and test what it is
by choroba (Cardinal) on May 24, 2022 at 09:42 UTC
    For changes not influenced by feature there's my Syntax::Construct (the link goes directly to the 0o section).

    Update: Fixed a typo, thanks Discipulus.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      Thanks for that. I also followed the link (in that doco) to Perl::MinimumVersion which may be rather useful in some upcoming tasks for $work (I wasn't previously aware of that module).

      — Ken

Re^8: Capture a non-printable char and test what it is
by afoken (Chancellor) on May 24, 2022 at 19:31 UTC
    I would never expect the "... && ... && ..." to be used in a real program.

    Not in the form shown here. But maybe in some degenerated cases in generated code.

    "# that's not perl: && ord($key) == 0o33"

    Actually it is; however, it's very new. See "perl5340delta: New octal syntax 0oddddd".

    Interesting. Redundant, as a leading zero already indicates octal since decades, no "o" required. And a nice complement to 0x and 0b.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Hi afoken

      Imo, not completely redundant. The 0o377 form has the advantage that it is a string literal that we know perl will interpret as a number, however that happens to be implemented in scalars.

      Whereas for the reader initiate the 0377 form can be somewhat ambigious, especially when they are preceded with a leading reference operator performing a similar disambiguation that may ultimately lead to further potentially uneccessary investigation on the part of the unfortunately bewildered acolyte.


      0x16-0xA==0xCoyote