--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
You did better than top-posting, but you'd better go further and trim
down the quoted material to the relevant parts you're commenting only.
In particular you should strip .sig's, well, unless you want to
discuss them, that is.
Thanks for reply. Yes i am trying to column count and compare tgroup
cols value. I have a huge xml file. thats why i was not added here. I
That's why I suggested you to take it and edit it to a bare minimum
still having the charachteristics you need to show what you want.
want to catch if tgroup cols="3" colspace(column) should be 3. If
colspace should be 4 then showing parse error.
No
use strict; # nor
use warnings; # too bad!
(The rationale being: ask perl to give you all the help it can, by
restricting your freedom in ways that will help you to prevent common
programming mistakes.)
Unused variable, and probably no need to initialize it if it were
used.
print "Enter the filename: ";
chomp($ram=<STDIN>);
open(RED,"$ram.xml");
Bareword FH, two-args and unckecked open().
BTW: So is $ram the filename or *part* of it?
open(MAD,">$ram.err");
Ditto.
print "WAIT! CHECKING IS IN PROGRESS ..... .....\n";
$cols=0;
Other unused variable.
Awkward indenting, bad style.
Attempt at manual XML parsing with regexen: bad! Use some XML parsing
module instead.
{
print MAD "LINE No. $cou: Trailing punctuations found before </title>
So $cou is for counting lines... don't! Just use $. instead. Read
about it in
perldoc perlvar
BTW: warning would better go to STDERR, possibly through the dedicated
warn() function.
{
print MAD "LINE No. $cou: Trailing punctuations found before </mono>
\n";
Ditto as above.
And then?!? I see no attempt at all at checking what you claimed to be
wanting to check.
I am confused how define tgroup cols value and count in
colspace(column) then it is not matching in tgroup cols value, should
be showing error msg. Value is not constant. Because so many tables in
XML files. All tables column is different. If table is 5 column,
tgroup cols="5".
Sort of. Without having a *sample* of your actual XML file (not the
whole of it), hard to give even a bare example. But IF the xml is as
regular as the snippet you showed in the last post, then something
just as rude as the following *may* work:
#!/usr/bin/perl
use strict;
use warnings;
while (<>) {
if (/<tgroup\s+cols\s*=\s*"(\d+)">/) {
my ($expected, $found)=$1;
$found++ while <>=~/<colspec/;
warn "Expected $expected cols, found $found at line $.\n"
unless $expected==$found;
}
}
__END__
PLEASE NOTE THAT THIS IS ADMITTEDLY BAD ADVICE AND IF YOU THINK OF
USING SOMETHING LIKE THIS ON A REGULAR BASIS, THEN IT'S LIKELY TO BITE
YOU IN THE NECK.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,