user:pass user1:pass1 use:pas
^ ^
####
user:pass
user1:pass1
use:pas
####
#!/usr/bin/perl
use 5.016;
use warnings;
# NOT JUST BTW: this will not work without modification for some possible 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";
}
####
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