Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Learning Programming, desperately need to know what information is contained in scalar variables

by Anonymous Monk
on Jul 20, 2020 at 21:10 UTC ( #11119567=note: print w/replies, xml ) Need Help??


in reply to Re: Learning Programming, desperately need to know what information is contained in scalar variables
in thread Learning Programming, desperately need to know what information is contained in scalar variables

I have the book Learning Perl in it there's a section called "Using Scalar-Producing Expressions in List Context" then it goes on to say "Going this direction is straightforward: if an expression doesn't normally have a list value, the scalar value is automatically promoted to make a one-element list:
@fred = 6 * 7; #gets the one-element list (42) @barney = "hello" . '' . "world";
In the first example, the array @fred on the left hand side of the operator = makes it a list context, did i got it right? In the second example, "hello" . '' . "world; alone is a scalar expression? Is the array @barney on the left hand side of the operator making it into list context like the first example?
  • Comment on Re^2: Learning Programming, desperately need to know what information is contained in scalar variables
  • Download Code

Replies are listed 'Best First'.
Re^5: Learning Programming, desperately need to know what information is contained in scalar variables
by LanX (Cardinal) on Jul 20, 2020 at 21:54 UTC
    Yes

    @something = ... ;

    or

    (...) = ... ;

    Are "list assignments".

    The RHS (right hand side) is in list context and the resulting list will be unpacked into the LHS.

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

Re^3: Learning Programming, desperately need to know what information is contained in scalar variables
by Anonymous Monk on Jul 20, 2020 at 21:14 UTC
    FIX EDIT: Is the array @barney on the left hand side of the operator = making it into list context like the first example?
      Yes

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11119567]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2020-10-23 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (234 votes). Check out past polls.

    Notices?