LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl script to list all files in a website (https://www.linuxquestions.org/questions/programming-9/perl-script-to-list-all-files-in-a-website-900675/)

jeethu 09-02-2011 03:05 AM

Perl script to list all files in a website
 
I have a website where some files are listed
say
Code:

GTP-UGP-LATEST-5.3.0.123.iso
GTP-UGP-LATEST-5.3.0.127.iso
GTP-UGP-LATEST-5.3.0.132.iso
GTP-UGP-LATEST-5.3.0.136.iso 
PRE-UGP-LATEST-5.3.0.124.iso
PRE-UGP-LATEST-5.3.0.126.iso
PRE-UGP-LATEST-5.3.0.127.iso
PRE-UGP-LATEST-5.3.0.130.iso

I am trying to write a perl script that can parse the HTML file and list all the files whoes name start from "GTP-UGP-LATEST-" and end from ".iso" and write it into a local file say gtp.txt.

Similary list all the files whoes name start from "PRE-UGP-LATEST-" and end from ".iso" and and write it into a local file say pre.txt.

Any idea how to parse with a HTML parser?

theNbomr 09-02-2011 04:51 PM

If the stated intention is the whole job, then I would simply use grep:
Code:

grep "PRE-UGP-LATEST-.*\.iso" yourFile.html > gtp.txt
If you really want to use Perl, then you should visit CPAN.org, and select one of the fine ready-made HTML parser modules there. Reliably parsing HTML is non-trivial, and you will do yourself a favor to use the existing work of experts.

--- rod.


All times are GMT -5. The time now is 03:20 PM.