System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: PERL for HTML file parsing

 
SOLVED
Go to solution
Highlighted
Super Advisor

Re: PERL for HTML file parsing

if you want one line then take variable and add every extracted value to it. then output it once:

$var="";
$var=$var.$value1;
$var=$var."\t".$value2;
$var=$var."\t".$value2;
..
$var=$var."\t".$value100;
print $var;


Highlighted
Frequent Advisor

Re: PERL for HTML file parsing

Buffer Cache: 5,984M 5,984M

if output is as above then i can find "buffer cache" from the parsed text file and print the whole line...which in turn will give the required value of buffer cache..i will pass it to a different text file ,ie,called as "final.txt".

then i will do same operation on my 2nd text file..and so on
and every time i will send buffer cache values to "final.txt"
then i can compare all the buffer cahe values in 100 report files
like this i have to do comparison of all variables
Highlighted
Super Advisor
Solution

Re: PERL for HTML file parsing

#!/usr/local/bin/perl


open SRC, "$ARGV[0]";
$/= undef;
$data=;
close SRC;


#take table string
$data =~ /$.*.*<\/table>.*/igs;
$data = $&;


#get read of html
$data =~ s///ig;
$data =~ s/

/\n/ig;
$data =~ s/<\/table>//ig;
$data =~ s///ig;
$data =~ s/><\/th>/>Column\t/ig;
$data =~ s/<\/th>/\t/ig;
$data =~ s/<\/TD><\/TR>//ig;
$data =~ s/<\/td>/\t/ig;
$data =~ s/<\/tr>//ig;
$data =~ s///ig;
$data =~ s///ig;
$data =~ s/\x20{2,}/\t/ig;
$data =~ s/ /\t/ig;
$data =~ s/\t{2,}/\t/ig;

print $data;


Save it to process.pl
and run
./process.pl your_report.html

Is it what you want?

Highlighted
Frequent Advisor

Re: PERL for HTML file parsing

great..u have understand my problem.

but i dont need the headings of the tables like "top 5 events",or table keys "event" "waits" "time(s)"
(it's ok...no prob if they are remaining there..but read below that if they are affecting or not the rest)...actually i need only table row values (see attached file)..every second variable values should go in next line(u can ignore this also).u can keep it as like as now also.

now let i have stored the values in a output1.txt file.similarly i will get 100 text files for 100 report files.

afterthat i need to get the value of "buffer hit" or "buffer cache" values from each of those 100 text files and redirect it to a file called "final.txt",ie,where it will be values of only buffer cache(or any other variables) recovered from 100 text files.then i can compare the values of buffercache values obtained from all report files.
Highlighted
Super Advisor

Re: PERL for HTML file parsing

I dont understand why you want to create hundered files from hundred files if using my way you can create final.txt immediatly from html files :)
Highlighted
Frequent Advisor

Re: PERL for HTML file parsing

by using which script i will get the "buffer cache" or "redo size" values from 100 html files???

the last one or the before used script..and how???
Highlighted
Super Advisor

Re: PERL for HTML file parsing

You run first version of script against your reports and output of every run of this script save to file - thus you get it in one file.
Highlighted
Frequent Advisor

Re: PERL for HTML file parsing

#!/usr/local/bin/perl


open SRC, "$ARGV[0]";
$/= undef;
$data=;
close SRC;


#take table string
$data =~ /$.*.*<\/table>.*/igs;
$data = $&;


#get read of html
$data =~ s///ig;
$data =~ s/

/\n/ig;
$data =~ s/<\/table>//ig;
$data =~ s///ig;
$data =~ s/><\/th>/>Column\t/ig;
$data =~ s/<\/th>/\t/ig;
$data =~ s/<\/TD><\/TR>//ig;
$data =~ s/<\/td>/\t/ig;
$data =~ s/<\/tr>//ig;
$data =~ s///ig;
$data =~ s///ig;
$data =~ s/\x20{2,}/\t/ig;
$data =~ s/ /\t/ig;
$data =~ s/\t{2,}/\t/ig;

print $data;


Save it to process.pl
and run
./process.pl your_report.html


this is your script...after running this it is giving output like this(attached)
now running everytime this script for html report i will get this type of output.
but i now i want to seperate out only single variable name(ie,buffer cache,redo size) with its values from different reports

i can't understand your last solution properly

Highlighted
Super Advisor

Re: PERL for HTML file parsing

You told you can find whole line with needed value - so take it from this output and compare
Highlighted
Frequent Advisor

Re: PERL for HTML file parsing

NHTEST 3848498958 NHTEST 1 10.2.0.2.0 NO baloo_a
Begin Snap: 1728 02-Feb-07 20:00:35 20 3.1
End Snap: 1729 02-Feb-07 21:00:35 23 3.7
Elapsed: 60.01 (mins)
DB Time: 0.27 (mins)
Buffer Cache: 5,984M 5,984M
but if it is this format then only i can find "buffer cache" and take the whole line out and then can compare...
can i print like this instead of printing as earlier(which looks same like the table).

pls tell me a solution pls...