#!/usr/bin/perl use strict; use warnings; my $tag; while () { #print "$_"; s/\s*<\s*(\/?)\s*(\w+)\s*>\s*/$1?"\n\n":"\n\n\{$2\}\n\n"/eg; print "After substitution: $_\n"; chomp; s/[\cA-\cZ]//g; # To remove control characters #print "Again printing the \$_ : $_\n"; s/^[\\|<]$//g; # To delete the character like \ and < at the end of the line s/[\\|<]$//; # To delete the character like \ and < at the begining of the line s/^\s+//g; # To remove multiple spaces at the begining of the line s/\s+$//g; # To remove spaces at the end of the line if(/^{(.*)}$/) { # match {METATAG} line $tag = $1; #print "The tag is $tag\n"; } } __DATA__ {SOURCETAG} 0904230634 {DATE} 090424 {EDITION} 1 {HEADLINE} heredero del famoso deportista mexicano, lucha por enaltecer la vida y obra del autor de sus dM-mas {SOURCE} Por Gisela Orozco 312.527.8461/ Chicago\ Por Gisela Orozco< TTL>312.527.8461/ Chicago