my @rgb = split /(\w{2})/, '4C4C45';
my (@rgb) = '4C4C45' =~ m/(\w{2})/g;
split /:/, "mehrere:verschiedene:sachen"
QuoteIf the PATTERN contains parentheses, additional list elements are created from each matching substring in the delimiter.
1
2
3
4
5
6
7
8
9
perl -wE'
my $string = "abc:def:ghi";
my @array = split /(:)/, $string;
say for @array'
abc
:
def
:
ghi
1
2
3
4
5
6
7
8
9
10
$ # Sonderzeichen und Verbindungslinien zur Verdeutlichung eingefügt
$ perl -MData::Dumper -e 'my @rgb = split /(\w{2})/, ".4C,4C-45"; print Dumper \@rgb;'
$VAR1 = [ | | |
'.', ---------------------------------------/ | |
'4C', | |
',', ------------------------------------------/ |
'4C', |
'-', ---------------------------------------------/
'45'
];