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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:10:34+00:00 2026-06-10T13:10:34+00:00

perldoc says a list assignment in scalar context returns the number of elements on

  • 0

perldoc says “a list assignment in scalar context returns the number of elements on the right-hand side of the list assignment” but when I try this code:

perl -e '$_="aaaaa";print $v=(()=split //)'

The output is 1 which makes me confused. (The answer I expect is 5.)

Can anybody explain this?

  • 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-10T13:10:36+00:00Added an answer on June 10, 2026 at 1:10 pm

    According to split documentation:

    When assigning to a list, if LIMIT is omitted, or zero, Perl supplies
    a LIMIT one larger than the number of variables in the list <…>

    Since you specify empty list, split only returns 1 result and this number of results is exactly what ends in your variable.

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

Sidebar

Related Questions

There is a lie that a list in scalar context yields the last element
I copied this example from perldoc -f sort . I added the @old array
According to the perldoc , the syntax for split is: split /PATTERN/,EXPR,LIMIT But the
From perldoc -f bless : bless REF,CLASSNAME This function tells the thingy referenced by
It appears that using perldoc perl gives the list of, e.g. perlre, perlvar, etc.
According to this http://perldoc.perl.org/UNIVERSAL.html I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or
I have read the perldoc on modules , but I don't see a recommendation
I have done some digging through perldoc and the O'Reilly books but haven't found
Does this ( perldoc unicode ) mean that all non-printable characters are control-characters? \p{Print}
I want to specify a signal handler in Perl, but using the number, not

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.