Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
<LINE> and < TTL> is replaced with {LINE} and {TTL} but it is not considered in the {METATAG} Line.#!/usr/bin/perl use strict; use warnings; my $tag; while (<DATA>) { #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 e +nd of the line s/[\\|<]$//; # To delete the character like \ and < at the beg +ining 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\ <LINE> Por Gisela Orozco< TTL +>312.527.8461/ Chicago</BYTTL>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regular expression ignores two lines
by Bloodnok (Vicar) on Aug 20, 2009 at 09:13 UTC | |
by Anonymous Monk on Aug 20, 2009 at 09:24 UTC | |
by Crackers2 (Parson) on Aug 20, 2009 at 12:48 UTC | |
by Bloodnok (Vicar) on Aug 20, 2009 at 09:36 UTC | |
by ashish.kvarma (Monk) on Aug 20, 2009 at 12:53 UTC | |
by Anonymous Monk on Aug 20, 2009 at 09:27 UTC |