use strict; use warnings; use Data::Dumper; my $templateformat = 'wbcmsw'; my $inputexample = 'w8b8cm512swno'; my @first_array = ($templateformat =~ /<([^>]*)>/g); my @second_array = ($inputexample =~ /\d+/g); printf "First array = %s\n", Dumper(\@first_array); printf "Second array = %s\n", Dumper(\@second_arrayt); # Displays: # # First array = $VAR1 = [ # 'NM', # 'NM', # 'CH', # 'SW' # ]; # # Second array = $VAR1 = [ # '8', # '8', # '512' # ];