#!"C:\perl\bin\perl.exe" -w # pragma use strict; use warnings; use diagnostics; # includes use Data::Dumper; my $string = '[-3|1|29x250+46+26|200+300+464|Get][-3|1|29x250+46+26|200+300+464|Get][-3|1|29x250+46+26|200+300+464|Get]'; sub getValues($) { my (@foo,@bar); foreach ( split( '\]\[', $_[0] ) ) { m/(\|[0-9x+]*){2}/g; push(@foo,$1); } foreach ( @foo) { m/\|(\d*)\w(\d*)\+(\d*)\+(\d*)/g; push(@bar, [ $1, $2, $3, $4 ] ); } return \@bar; } print Dumper getValues($string); #### $VAR1 = [ [ '29', '250', '46', '26' ], [ '29', '250', '46', '26' ], [ '29', '250', '46', '26' ] ];