#!/usr/bin/perl $Free=1; if($ARGV[0]) { open(RAW,$ARGV[0]) || die("Can't open input file!\n$!\n"); my(@Temp) = split(/\./,$ARGV[0]); $OutFile = "$Temp[1].$Temp[2].txt"; open(COOK,">$OutFile") || die("Can't open output file!\n$!\n"); } else { open(RAW,"<&STDIN"); open(COOK,">&STDOUT"); } while() { chomp(); s/^\s*$//g; # remove newline, and whitespace-only lines my($Line) = $_; if($Line =~ /\/) { if($Line =~ />([^<>]+)<\//) { print COOK "$1\n"; } } if($Line =~ /^([^<>]+)<\/.+>([^<>]+)<\/.+>([^<>]+)<\/.+>([^<>]+)<\//) { if($1 ne ' ') { print COOK "$1 "; } print COOK "$2 $3 $4\n"; } else { if($Free) { print "Funky error in $ARGV[0]\n$Line\n"; } $Free=0; } } if($Line =~ /^