Interesting this ideone if it really lets you run actual perl code, anyway, its best in the future if you also post the code here in code tags, here is the output on my machine
#!/usr/bin/perl
use strict; use warnings;
use Data::Dumper;
my $text = 'XYYYZ';
my @source;
push @{$source[$1 ? 0 : $2 ? 1 : 2]}, $& while $text =~ /(X)|(Y)|(Z)/g
+;
print Dumper \@source;
__END__
$VAR1 = [
[
'X'
],
[
'Y',
'Y',
'Y'
],
[
'Z'
]
];
update: yeah wrong window, pasted the wrong ideone, fixed |