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 283931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:24:55+00:00 2026-05-12T05:24:55+00:00

I got this strange line of code today, it tells me ’empty’ or ‘not

  • 0

I got this strange line of code today, it tells me ’empty’ or ‘not empty’ depending on whether the CWD has any items (other than . and ..) in it.

I want to know how it works because it makes no sense to me.

perl -le 'print+(q=not =)[2==(()=<.* *>)].empty'

The bit I am interested in is <.* *>. I don’t understand how it gets the names of all the files in the directory.

  • 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-05-12T05:24:55+00:00Added an answer on May 12, 2026 at 5:24 am

    It’s a golfed one-liner. The -e flag means to execute the rest of the command line as the program. The -l enables automatic line-end processing.

    The <.* *> portion is a glob containing two patterns to expand: .* and *.

    This portion

    (q=not =)
    

    is a list containing a single value — the string “not”. The q=...= is an alternate string delimiter, apparently used because the single-quote is being used to quote the one-liner.

    The [...] portion is the subscript into that list. The value of the subscript will be either 0 (the value “not “) or 1 (nothing, which prints as the empty string) depending on the result of this comparison:

    2 == (()=<.* *>)
    

    There’s a lot happening here. The comparison tests whether or not the glob returned a list of exactly two items (assumed to be . and ..) but how it does that is tricky. The inner parentheses denote an empty list. Assigning to this list puts the glob in list context so that it returns all the files in the directory. (In scalar context it would behave like an iterator and return only one at a time.) The assignment itself is evaluated in scalar context (being on the right hand side of the comparison) and therefore returns the number of elements assigned.

    The leading + is to prevent Perl from parsing the list as arguments to print. The trailing .empty concatenates the string “empty” to whatever came out of the list (i.e. either “not ” or the empty string).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got this line of code here but its not working. private void Button_Click(object sender,
Has anyone seen this very strange behaviour before? I've got a solution whith 70
I've got a strange issue. This is suddenly started happening in the code that
I’ve got this strange problem whereby the content within a scroll viewer increases in
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
I've got this strange problem using py-amqp and the Flopsy module. I have written
this is strange, I've got a macro with an array containing several registry keys.
I've got some strange behaviour happening I can't work out. I've written some code
today i was facing a strange problem: got a 'missing method' error on a
this is pretty strange. I've got this string that connect to a SQLServer in

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.