LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2011, 03:05 AM   #1
jeethu
LQ Newbie
 
Registered: Oct 2009
Posts: 14

Rep: Reputation: 3
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?

Last edited by jeethu; 09-02-2011 at 03:11 AM.
 
Old 09-02-2011, 04:51 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
config apache server to list php, c/c++, java files as regular txt on website, aronaron Linux - Server 1 02-03-2011 12:49 AM
Need advice on a script to search many files for list of terms, append hits to list jimmy the saint Programming 1 07-11-2010 03:59 AM
To rename files in a directory should I use Bash script or a Perl Script ? jamtech Programming 7 01-22-2008 11:25 PM
How do I replace text with perl with a list fo files? nadavvin Programming 7 09-14-2006 07:12 PM
Perl script for website won't work klintonray Programming 5 07-27-2003 06:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration