Perl Monk, Perl Meditation PerlMonks

### comment on

 Need Help??

\(LIST) is documented to return a list of references to each member of the LIST in some cases.

```>perl -e"print qq{\$_: \$\$_\n} for \( 'a', 'b', 'c' );"
SCALAR(0x239b9c): a
SCALAR(0x239c9c): b
SCALAR(0x239cec): c

>perl -e"print qq{\$_: \$\$_\n} for \qw( a b c );"
SCALAR(0x239b9c): a
SCALAR(0x239c9c): b
SCALAR(0x239cec): c

>perl -e"@a = qw( a b c ); print qq{\$_: \$\$_\n} for \(@a);"
SCALAR(0x239bac): a
SCALAR(0x239c5c): b
SCALAR(0x239cac): c

>perl -e"@a = qw( a b c ); print qq{\$_: @\$_\n} for \@a;"
ARRAY(0x1829a04): a b c

Same goes for subs, apparently.

```>perl -e"print qq{\$_: \$\$_\n} for \sub { qw( a b c ) }->();"
SCALAR(0x239c5c): a
SCALAR(0x239cac): b
SCALAR(0x239cbc): c

Update: Clarified some.

Update: This differs from x's behaviour

```>perl -le"@a = 'a' x 5; print 0+@a"
1

>perl -le"@a = ('a') x 5; print 0+@a"
5

>perl -le"@a = qw( a ) x 5; print 0+@a"
5

>perl -le"@a = sub { qw( a ) }->() x 5; print 0+@a"
1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Are you posting in the right place? Check out Where do I post X? to know for sure.
• Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
• Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
• Want more info? How to link or How to display code and escape characters are good places to start.

Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-03-23 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Which type of climate do you prefer to live in?

Results (60 votes). Check out past polls.

Notices?