#!/usr/bin/perl use strict; use warnings; my $tag; while () { s/\s*<\s*(\/?)\s*(\w+)\s*>\s*/$1?"\n\n":"\n\n\{$2\}\n\n"/ge; 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 (/^\{(.*)\}$/) { $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 #### The tag is SOURCETAG The tag is DATE The tag is EDITION The tag is HEADLINE The tag is SOURCE