Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

The Backslash Challenge

by choroba (Archbishop)
on Mar 24, 2021 at 20:12 UTC ( #11130291=obfuscated: print w/replies, xml ) Need Help??

To return the character that's used as the delimiter in a quote-like operator, you can use a backslash.
'/' eq q/\// or die "Failed";

Your task is to return a backslash using a backslash as the delimiter. Use qq\\ for level easy, use q\\ for level guru.

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

Replies are listed 'Best First'.
Re: The Backslash Challenge
by choroba (Archbishop) on Mar 24, 2021 at 22:11 UTC
    OK, here are some solutions I was able to find:

    -->>

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

      Two more options

      • Encode::encode("cp1047","*")
      • charnames::string_vianame("REVERSE SOLIDUS")

      Enjoy, Have FUN! H.Merijn
Re: The Backslash Challenge (updated)
by haukex (Bishop) on Mar 24, 2021 at 20:29 UTC
      > then I clicked on your spoiler...

      I should have done this earlier ...

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Re: The Backslash Challenge
by LanX (Sage) on Mar 25, 2021 at 02:18 UTC
      Nice trick!

      Interestingly, it doesn't work for me. In the debugger, I'm getting

      cont: Can't find string terminator "\" anywhere before EOF at (eval 13)[/usr +/lib/perl5/5.26.1/perl5db.pl:738] line 2. at (eval 13)[/usr/lib/perl5/5.26.1/perl5db.pl:738] line 2. eval '' called at /usr/lib/perl5/5.26.1/perl5db.pl line 738 DB::eval called at /usr/lib/perl5/5.26.1/perl5db.pl line 3140 DB::DB called at -e line 1

      And if I run it in a script instead, the output is _, not \ :-o

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

        A backslash at EOL marks a multiline statement in DB. I had a trailing whitespaces to avoid this, but the C&P from cmd.exe erased them. :( Fixed now!

        > And if I run it in a script instead, the output is _, not \ :-o

        both lines? lemme check...

        ...

        Argh! Seems that the context of the debugger is initializing a "crucial thing" which can't be taken for granted :(

        update

        yes a use DB; at the start of the script is "fixing" it.

        Actually that could be a source of a Heisenbug.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Re: The Backslash Challenge
by LanX (Sage) on Mar 24, 2021 at 20:56 UTC
        yeah I updated something similar.

        Mine is simpler, yours is less cheating... more obfuscated! ;-)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-10-19 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (76 votes). Check out past polls.

    Notices?