#!/usr/bin/perl use strict; use warnings; my $tag; my $output; my $fh; my $deletestrings; #open DATA,"$ARGV[0]"; while () { chomp; s/[\cA-\cZ]//g; # To remove control characters #To delete the lines which has {IT} and any lines between {IT} and {SOURCETAG} if (/\{IT\}/ .. /^\{SOURCETAG\}/) { unless (/^\{(IT|SOURCETAG)\}/) { $deletestrings = $_; $_ = '' if index( $_, "$deletestrings" ) >= 0; } } s/[\\|<]$//g; s/^[\\|<]//g; s/$_"; } } $fh = output($output, $tag, $fh); if($fh) { print $fh "\n"; close($fh); } exit(0); sub output { my ($output, $tag, $fh) = @_; if($output) { if($output =~ m/(.*)/) { if($fh) { print $fh "\n"; close($fh); } open($fh, '>', "$1.xml") or die "$1.xml: $!"; print $fh "\n\n"; } print $fh "$output\n"; } return($fh); } __DATA__ ^C^D^V^V^A exit 0543 961017 N S 9702050900 00000000^B{IT} N {SOURCETAG} 9702050900 {ACCESSION} 000000 {DATE} 961017 {TDATE} Thursday, October 17, 1996 {PUBLICATION} EXITO {EDITION} Exito {SECTION} SALUD FAMILIAR {PAGE} 22 {SOURCE} Por Nahyr Acosta. Colaboradora de ¡Exito! {COLUMN} Nuestro hijos. {HEADLINE} EVITE LA ENFERMEDAD PERIODONTAL< AS {LEAD}CTIQUE LA HIGIENE DENTAL PARA CUIDAR SUS ENCà Cuando hace casi dos años visité a mi dentista para hacerme un chequeo dental , me encontré ante un problema que podía terminar con mi dentadura. Siempre tuve unos dientes sanos y jamás se me ocurrió pensar que podía perder mis piezas si no tomaba acción inmediata. Me puse en manos del dentista y empezamos a trabajar en mis encías.<