#!/usr/bin/perl use warnings; use strict; use Data::Dumper; sub foo { my $array_ref = ["foo" , "enum('bar,baz')"]; if($array_ref->[1] =~ /enum\('(.*?)'\)/) { return split ",", $1; } } print Dumper(foo());