No such thing as a small change | |
PerlMonks |
Re: Parse Pipe Delimited Textby tinman (Curate) |
on Apr 03, 2001 at 03:27 UTC ( [id://69145]=note: print w/replies, xml ) | Need Help?? |
I see three main problems that you need to solve here firstly, you need to parse a pipe delimited file. Ok, for this, you can use the CPAN module Text::CSV_XS You could of course, also roll your own, with a simple call to the split function such as (this is very simplistic, probably too much so)
Your second problem is to find out when a new file has arrived.. First, store the modified date of the file with a call to the Perl inbuilt function stat, or by using the File::Stat module. Whenever your Perl script wakes up (cron job? or NT 'at' scheduler call)and decides to process the file, check the last modified date that you stored, with the one of the file. If they differ, ie: if the FTP folder file has a more recent date, that means you should parse the file again... Well, the third problem, outputting to an HTML table, is sort of simple, I think.. for completeness sake, I'll put a small pseudo-code like segment here that describes how it would be done...please note: this is untested
HTH Update: Fixed the code segments.. ack, can't believe I didn't put that in :(.. much respect to MrNobo1024 Update 2: Changed the name of the file handle from the reserved DATA to INPUT. DATA still works, but its not very good practice, as pointed out by others.
In Section
Seekers of Perl Wisdom
|
|