my $tmpComments = File::Temp->new(SUFFIX=>'.txt') or die "File::Temp: $!\n"; foreach (#Go through the whole xml file) { if ($type eq 'Comment') { # Parse the xml and save the parts as variables print $tmpComments "$posturl~~~$date~~~$author~~~$content\n"; # $posturl holds the url } }