#!/usr/bin/perl use strict; use warnings; my $fh; my $tag; while(){ chomp $_; $_ =~ s/[\cA-\cZ]//g; #$_ =~ s/^\s+$//g; #$_ =~ s/\n//g; #$_=~ s/[\r]//gs; if(/^{(.*)}/) { $tag = $1; print $tag."\n";; } else { if($tag eq 'FILE') { my $filename = $_; # print "The filename is $filename\n"; open($fh, '>', "$filename.xml") or die "$filename: $!"; print $fh '',"\n"; print $fh "\n"; print $fh "$filename"; } elsif(defined($fh)) { if( $_ ne ''){ #### Remove the blnak lines chomp $_; print $fh "<$tag>$_\n"; } #print $fh ""; } } } close($fh); exit(0); __DATA__ ^B^B^B^B^B^B {FILE} sourcetag1 {NUMBER} 00000 {SOURCE} source1 {KEYWORD} {AUTHOR} author1 staff1 {HEADLINE} DISPOSABLE DECOR: THE CUTTING EDGE DULLS FAST\ STYLE AT A SPEED USUALLY ASSOCIATED WITH WARDROBE ITEMS. {FILE} sourcetag2 {NUMBER} 00002 {SOURCE} sourcenam2 {KEYWORD} {AUTHOR} author2 staff2 #### sourcetag100000 source1 author1 staff1 DISPOSABLE DECOR: THE CUTTING EDGE DULLS FAST\ STYLE AT A SPEED USUALLY ASSOCIATED WITH WARDROBE ITEMS.