Could someone please spare sometime lookinto the below issue?
Script:
#!/usr/local/bin/perl use strict; use warnings; undef $/; chomp($input=$ARGV[0]); open (A, "< $input") || die "Couldn't open the input"; open(B, ">A.xml") or die("Sorry!"); while (<A>){ $_=~s/\s\s//gi; $_=~s/\t//gi; $_=~s/^\n$//gi; $_=~s/\n//gi; $_=~s/’/'/gi; $_=~s/—/—/gi; $_=~s/“/“/gi; $_=~s/â€/”/gi; print B $_; } close (A); close (B); open(C, "< A.xml") || die "$!"; open (Z, "> $input.sgm") || die "Can't write the output"; $file = <C>; #Body matter begins if ($file =~ m/(<Body [^>]*>(.*?)<\/Body>)/){ $xmlBody = $1; #. #. #. #Processing BlockAmendments while ($xmlBody =~ m/(<BlockAmendment [^>]*>(.+?)<\/BlockAmendment +>)/sgi){ $CbBlkTx = $1; $bBlkTx = $CbBlkTx; if ($bBlkTx =~ m/(<BlockAmendment [^>]+><P2>(.*?)<\/P2><\/Bloc +kAmendment>)/){ $bBlkTx =~ s/<BlockAmendment [^>]+><P2>(.*?)<\/P2><\/Block +Amendment>/\n<lq><P2>$1<\/P2>\n<\/lq>/gi; $bBlkTx =~ s/<P2><Pnumber>([^<]+)<\/Pnumber><P2para><Text> +(.+?)<\/Text>(.*?)<\/P2para><\/P2>/\n<s1><no>($1)<\/no>\n<pt>$2<\/pt> +$3\n<\/s1>/mgi; $bBlkTx =~ s/<P3><Pnumber>([^<]+)<\/Pnumber><P3para><Text> +(.+?)<\/Text>(.*?)<\/P3para><\/P3>/\n<s2><no>($1)<\/no>\n<pt>$2<\/pt> +$3\n<\/s2>/mgi; $bBlkTx =~ s/<P4><Pnumber>([^<]+)<\/Pnumber><P4para><Text> +(.+?)<\/Text>(.*?)<\/P4para><\/P4>/\n<s3><no>($1)<\/no>\n<pt>$2<\/pt> +$3\n<\/s3>/mgi; $bBlkTx =~ s/<P5><Pnumber>([^<]+)<\/Pnumber><P5para><Text> +(.+?)<\/Text>(.*?)<\/P5para><\/P5>/\n<s4><no>($1)<\/no>\n<pt>$2<\/pt> +$3\n<\/s4>/mgi; } $bBlkTx =~ s/<\/pt>\n<\/s([0-9])><Text>(.+?)<\/Text>/ $2<\/pt> +<\/s$1>/mgi; print "$CbBlkTx\n\n============\n"; print "$bBlkTx\n\n"; $xmlBody =~ s/$CbBlkTx/$bBlkTx/gi; } } print Z $xmlBody;
I'm sending you only the problamatical section from the script.
Requirement:
Issue:
#3 point has not performing within while loop!
could you please helpout in this?
Below are the two piece of particular input and required output
piece of input:
<BlockAmendment Context="unknown" TargetClass="unknown" TargetSubClass +="unknown" Format="double"> <P2> <Pnumber>3</Pnumber> <P2para><Text>At the time when the order is drawn up, the court office +r will—</Text> <P3> <Pnumber>a</Pnumber> <P3para><Text>where the order made is (or includes) a non-molestation +order; or</Text> </P3para> </P3> <P3> <Pnumber>b</Pnumber> <P3para><Text>where the order made is an occupation order and the cour +t so directs,</Text> </P3para> </P3> <Text>issue a copy of the order, indorsed with or incorporating a noti +ce as to the consequences of disobedience, for service in accordance +with paragraph (2).</Text> </P2para> </P2> </BlockAmendment>
piece of output:
<lq> <s1><no>“(3)</no> <pt>At the time when the order is drawn up, the court officer will&mda +sh;</pt> <s2><no>(a)</no> <pt>where the order made is (or includes) a non-molestation order; or< +/pt> </s2> <s2><no>(b)</no> <pt>where the order made is an occupation order and the court so direc +ts, issue a copy of the order, indorsed with or incorporating a notic +e as to the consequences of disobedience, for service in accordance w +ith <cit><loc>paragraph (2)</loc></cit>.”.</pt> </s2></s1> </lq>
Thanks in Advance,
Thirilog
In reply to Help required inText manipulation by thirilog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |