Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Trying to capture a value from a list of values

by Not_a_Number (Prior)
on Sep 02, 2015 at 13:19 UTC ( [id://1140791]=note: print w/replies, xml ) Need Help??


in reply to Re: Trying to capture a value from a list of values
in thread Trying to capture a value from a list of values

my $lnxsrvrs = "@mylnxsrvrs";
This will assign to $lnxsrvrs the number of elements of the @mylnxsrvrs array.

Actually, it won't.

Since @mylnxsrvrs is in double quotes, the contents of the array are concatenated and stringified, and this string is assigned to $lnxsrvrs.

Consider:

my @array = ( qw/ un deux trois / ); my $count = "@array"; print $count;

Output:

un deux trois

How the OP (thinks they) got an output of 1 remains a mystery...

Replies are listed 'Best First'.
Re^3: Trying to capture a value from a list of values
by Laurent_R (Canon) on Sep 02, 2015 at 13:31 UTC
    Oh course, you're right, Not_a_Number ++, silly mistake on my part, I actually saw it myself when reviewing my post right before reading your answer. I answered to fast and I had not paid attention to the quotes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-19 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found