#!/usr/bin/perl use warnings; use strict; use diagnostics; use Data::Dumper; my @contents = ( [qw/html head body/], [qw/font face size color/], [qw/h1 p code/]); my @ctags; foreach my $row (@contents) { #$row will now be an array reference; #print Dumper $row; # if you want to see foreach my $value (@$row) { push @ctags, "<\\$value>"; } } print Dumper(\@ctags);