in reply to 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.

But if this array has only one element, the it means that your split did not yield two fields as you seem to expect. Are you sure your fields are comma-separated? From your own OP, it might be space-separated values.

Please check what you really have and clarify.

Update: : forget what I crossed out, I had not paid attention to the quotes, which are changing everything. Still, plus specify your input: in one case it appears to be comma-separated, and in another post, space separated.

Replies are listed 'Best First'.
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
    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...

      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.