Re: Newbie Help (WinXP)



Mark Jerde wrote:
There are 228 .html files I want to suck 4 items out of and put in a single comma delimitted file, one line per .html file. I know how to build the regular expressions to get the 4 items.

OK. Show us.

I know how to do this in *.NET and VB6 but I wanted to try to do it in Perl. I downloaded perl from ActiveState.com and have successfully run a few programs but I'm not being successful processing *.html on the command line.

Why don't you show us what you've tried. Then someone can give pointers as to where you're going wrong.


I would really appreciate it if someone would reply with the WinXP command line and the Perl program to make a single output file of [Father, Mother] from *.html input. Sample input:

1.html

Person=George
Father=Alan
Mother=Sarah
Hobby=Cheating at dice

2.html

Person=Karen
Father=David
Mother=Mary
Hobby=Burning books

3.html

Person=Mark
Father=Sven
Mother=Helga
Hobby=Burping

Output file:

Alan, Sarah
David, Mary
Sven, Helga



In linux this works for one file at a time:

perl -lne 'if (/(Father|Mother)=(\w+)/) {push @data, $2} END{print join(",", @data)}' 1.html

I'll leave it as an exercise for the OP to modify it to output correctly for *.html. I could do it as a script, but I'm sure it's possible on a one-liner.
.




Relevant Pages

  • OT: writing pdf from perl
    ... I currently have a perl program with which I read an xml file (of dictionary ... entries), sort and format the entries and print them out (as html). ... I can see how I could so this from C# using the printer classes (and ...
    (comp.lang.perl.misc)
  • Re: CGI.pm and lost carriage returns
    ... HTML form with a textarea input box, I would like my Perl program to see the ... IMHO, If someone wants to do serious CGI programming, s/he really needs ... to get a book that fills in the gaping holes in the perldocs. ...
    (comp.lang.perl.misc)
  • Re: Click link to go to routine
    ... You've tried more than once to get answers in this newsgroup and not managed it. ... If you want to do something special in a Perl program as a result of that URL then you have to ... You do in standard Perl, using the CGI interface to retrieve the parameters and then code branches appropriately. ... If the HTML is generated by a Perl program in the first place then you can usually use the same program as the target of the link, using hidden fields in the HTML to distinguish between different invocations of the program. ...
    (comp.lang.perl.misc)
  • Re: A-Z listing
    ... It sounds very promising. ... > That can be done without using perl in HTML (or CGI) code. ... > Write a perl program that can be run from the command line which will ...
    (comp.lang.perl.misc)
  • scalability of perl cgi programs that load text files
    ... Suppose you have a perl program that is called by a web page to ... The program is written to load data from a ... text prior to the output of html. ...
    (comp.lang.php)