Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Dilbert don't warn!

by tobyink (Abbot)
on Jul 08, 2013 at 09:38 UTC ( #1043056=obfuscated: print w/ replies, xml ) Need Help??

This is an interesting feature of Perl that's recently come up on p5p as a candidate for removal. Not obfuscated, but obscure certainly.

#!/usr/bin/env perl use warnings; "pointy haired boss"; "dilbert"; "dogbert"; "wally";

Outputs:

Useless use of a constant ("pointy haired boss") in void context at sc +ratch.pl line 5. Useless use of a constant ("dogbert") in void context at scratch.pl li +ne 7. Useless use of a constant ("wally") in void context at scratch.pl line + 8.

What? Why doesn't "dilbert" generate a warning?

Turns out that before pod became the standard for Perl documentation, people used to embed strings of nroff in Perl scripts. Any strings that begin with "di", "ds" or "ig" look enough like bits of nroff to be exempt from the void warning.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Comment on Dilbert don't warn!
Select or Download Code
Re: Dilbert don't warn!
by hdb (Parson) on Jul 08, 2013 at 09:44 UTC

    Do you think this is one of the reasons why Scott Adams called Dilbert Dilbert?



Re: Dilbert don't warn!
by ambrus (Abbot) on Jul 08, 2013 at 10:43 UTC

    NOOO! The want to break another of my precious obfus, namely Digisig this time?

Re: Dilbert don't warn!
by choroba (Abbot) on Jul 08, 2013 at 10:56 UTC
Re: Dilbert don't warn!
by LanX (Canon) on Jan 04, 2014 at 08:49 UTC
    hmm interesting.

    I missed that discussion during my holidays.

    Maybe a drift, but if the parser already has the ability to special case void strings, then this could be a chance to implement docstrings ... :)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://1043056]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-08-21 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (141 votes), past polls