use strict; foreach $file (@NetIncludeDir) { ($network, $path) = $file =~ m<^( (?:\+ \w+){2} )(.*)>x; print "Network: $network, Path: $path\n"; }