globaldre has asked for the wisdom of the Perl Monks concerning the following question:
Hello - I am a .Net developer with very limited Perl knowledge. I am attempting to read some values from several files and output the value as a csv file. I can write an .exe in C# that can accomplish this, but due to security concerns I am not able to run a .exe on the server. I know Perl is already installed on the server and running a Perl script wouldn't raise any concerns. I've been reading through several Perl books, but haven't come across any examples on how to get this done. Any ideas/suggestions is greatly appreciated.
I have some files in a directory that looks like this:
1. - root
1.1 - html
1.1.1 - html2010
file1.html
file2.html
file3.html
etc
1.1.2 - html2010
file1.html
file2.html
file3.html
I need to read the content from the "description" and "keywords" meta (test1,test2,test3,testk1,testk2,etc) from each file and output it as a csv file.
The html pages look something like this:
<!-- File 1 --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/T +R/html4/strict.dtd"> <html lang="en" dir="ltr"> <head> <title>Test Page1</title> <meta name="description" content="test1,test2,test3,test4,test5"/> <meta name="keywords" content="testk1,testk2,testk3,testk4,testk5"/> </head> <body> Body of the page 1 </body> </html>
<!-- File 2 --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/T +R/html4/strict.dtd"> <html lang="en" dir="ltr"> <head> <title>Test Page2</title> <meta name="description" content="test6,test7,test8,test9,test10"/> <meta name="keywords" content="testk6,testk7,testk8,testk9,testk10"/> </head> <body> Body of the page 2 </body> </html>
I have a very limited understanding of Perl. Feel free to make a recommendation if you think there is another scripting language that is more suitable for accomplishing the above task
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting Data from a File
by Tanktalus (Canon) on Nov 11, 2010 at 15:17 UTC | |
by Corion (Patriarch) on Nov 11, 2010 at 15:19 UTC | |
by globaldre (Initiate) on Nov 11, 2010 at 18:59 UTC | |
|
Re: Extracting Data from a File
by PeterPeiGuo (Hermit) on Nov 11, 2010 at 16:33 UTC | |
|
Re: Extracting Data from a File
by roho (Bishop) on Nov 11, 2010 at 18:58 UTC | |
by globaldre (Initiate) on Nov 12, 2010 at 13:38 UTC |