I think I understand that you have some data (we'll discuss list later) comprised of something like this:

user:pass user1:pass1 use:pas ^ ^

What is the separator (ie, the character my caret's point to)? A space, semi-colon, LF, null or something else (including no separator at all)?

Now, as to "list" -- what's shown is a list. But is that what your source looks like (minus the assignment and the rest of the Perl-ish elements, or does your source look like this?

user:pass user1:pass1 use:pas

or, perhaps, like this (markup typo fixed here; thanks, kcott!)

user:pass,user1:pass1,use:pas

For the first, a simple split statement will do very nicely; the second begs that you read the data into an array and use for $_(@array){.... while the third looks like an invitation to use the appropriate csv module to put you data into a format you know how to mung.

Update (illustration):

#!/usr/bin/perl use 5.016; use warnings; # NOT JUST BTW: this will not work without modification for some possi +ble forms of data! my $list = "user:passer use:pass user1:pass1"; say $list; say "That was \$list; these are the elements of \@arr:"; my @arr= split / /, $list; for (@arr) { say $_; my $current_element = $_; my ($first, $second) = split /:/, $current_element; say "\$first: $first & \$second: $second"; }

Output:

user:passer use:pass user1:pass1 That was $list; these are the elements of @arr: user:passer $first: user & $second: passer use:pass $first: use & $second: pass user1:pass1 $first: user1 & $second: pass1
Come, let us reason together: Spirit of the Monastery

In reply to Re: Parsing list by ww
in thread Parsing list by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.