Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:28:55+00:00 2026-06-04T13:28:55+00:00

I was fooling around with some obfuscated code that doesn’t do anything useful when

  • 0

I was fooling around with some obfuscated code that doesn’t do anything useful when I encountered some strange behaviour I did not understand.

Here’s my code.

no strict;
sub foo{1&&{${$_[0]},${$_[0]}}}say map {&${${_}}(${_})->{${${_}}}}map{\$_}qw(foo);

And in indented:

no strict;
sub foo {
  1 && { ${$_[0]} => ${$_[0]} }
}
say map { &${ ${_} }( ${_} )->{ ${ ${_} } } }
  map { \$_ } qw (foo);

What it should do is take the string foo, build a reference to it, and then call the function with that name (&foo). That function should return a hashref where both key and value are said foo string. After that, it prints the value of the returned hashref’s key foo, which is foo.

So far, so good. Not useful, but still fun. The strange thing is, when I remove the 1 && part in the sub, it returns a list despite the curlies, and I have no clue why it does that.

If I just say sub foo { { 'foo'=>'foo' } } it returns the reference. Why doesn’t it in my case? And furthermore, why does it when I add 1 &&?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:28:56+00:00Added an answer on June 4, 2026 at 1:28 pm

    Without the 1 && part the curly braces are interpreted as a block thus returning a list. With the additional part the perl interpreter makes an anonymous hashreference as desired.

    Instead of the 1 && you could also use a simple + to help the perl interpreter:

    sub foo {
      +{ ${$_[0]} => ${$_[0]} }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been fooling around with code for ages on this one, I would be
I had been fooling around with an initial splash screen but decided not to
I've just been fooling around with a ListBox control that I want to style
I am fooling around with this function that says if you leave this text
I was just fooling around with some Domain Specific Language designs for a new
I'm fooling around with Yahoo! pipes and I'm hitting a wall with some regular
I'm recently fooling around with some ajax polling techniques. However, it seems like I
I referenced the code from Android Developer. After compliling the code and fooling around
I was fooling around with some functional programming when I came across the need
I've been fooling around with malloc, realloc and free in order to write some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.