sub splitNode2{ my ($name, $root, $tag, $filename) = @_; #print "opening file [$filename]\n"; if(!open(READ, "$filename")){ die "Cannot open file [$filename] for reading\n"; } my $content = ""; while(my $line = ){ $content .= $line; } #print "matching <$tag>\n"; my @matches = $content =~ /(<$tag.*?>.*?<\/$tag>)/sg; if(scalar(@matches) < 1){ writeFile($name, "", $content); #writes the string to a file return 0; } my $count = 1; foreach (@matches){ writeFile("$name"."_"."$count", "", $_); $count++; #print "match: $_\n\n\n"; } }