$ perl foo.pl ServiceCategoryName=foo,bar,baz my string foo $ cat foo.pl use strict; use warnings; my $str = "ServiceCategoryName=foo,bar,baz\n"; if ( $str =~ m/^ServiceCategoryName=(.*)/) { print $str; # Extract the array from "the rest of the line" my @array = split /,/, $1; print "my string ", $array[0], "\n"; } else { print "Can't find ServiceCategoryName!\n"; }