# $filter holds regex statements # e.g. s/(F01-861385.*);;/\1;Categroy1;SubCategory2/g open(REGEX, "<$filter"); while() { next if ($_ =~ m/^\s*#.*$/); chomp; $regex .= "$_, "; } close(REGEX); # pre formatted csv content in $lines for (split /^/, $lines) { chomp; $_ =~ eval($regex); # ... # extract fields and build up SQL INSERT INTO }