in reply to HTML-Parser: a newbie question: need to extract exactly line 999 out of 5000 files..

I must admit that I find it quite remarkable that a line number is actually the deciding factor... Are you absolutely sure that this is true, “in the general case?”

The solution that you were just offered is what we affectionately call, “a one-liner.”   In other words, it absolutely is possible to extract the 999th line from a directory-full of files in just one line of code.   But you should consider this kind of revelation to be illustrative, not necessarily a general solution.

Please do this:   describe, as best you can, what you really want to get, and, what you really want to do with it.   Believe me when I say these three things:

  1. Whatever it is, Perl can do it ... (fairly) effortlessly.   (In other words, “that is what all the fuss is about!”)
  2. Everyone here has been exactly where you are, and understands your uncomfortable situation implicitly.   (Some might say that we are here because Perl “saved our backsides” in the past, and we never forgot the favor.)
  3. Although we can’t promise to “do your work for you” (and of course, no one seriously expects that that you expect such a thing from us...), we would be quite pleased to demonstrate just how quickly, and just how decisively, Perl can put your mind at ease...

The many people who have observed that “Perl is the Swiss Army Knife® of professional programming,” were 100% accurate.

Replies are listed 'Best First'.
Re^2: HTML-Parser: a newbie question: need to extract exactly line 999 out of 5000 files..
by morgon (Priest) on Oct 16, 2010 at 01:25 UTC
    Are you absolutely sure that this is true, “in the general case?”
    Of course it is not true in the "general case" and nobody ever claimed that.

    I understand the question to be a one-off task to move the content of 5000 machine-generated html-files into a database.

    That in such a scenario you use all available information to make the task easier is only natural.

      hello Morgon hello sundialsvc4 -

      thanks for the kind words and for opening my eyes for the power of PERL !

      that is just amazing! Well i get a headace when i see to browse 5000 files and do all the work by hand. This would take more than several weeks.

      so i decide to use PERL - since it is very very powerful - i try to nail down the issues while using PERL.

      See one of the example sites: http://www.kultusportal-bw.de/servlet/PB/menu/1188427/index.html?COMPLETEHREF=http://www.kultus-bw.de/did_abfrage/detail.php?id=04313488
      in the grey shadowed block you see the wanted information: 17 lines that are wanted. Note - i have 5000 different HTML-files - that all are structured in the very same way!

      That means i would be happy to have a template that can be runned with HTML::TokeParser::Simple and DBI.
      That would be great!!

      ,,, and now i try to get more infos about HTML::TokeParser::Simple and DBI.... I have a manual of DBI - The book of Tim Bunce and aligator xy! At the moment i am on page 25... ;-)

      @Morgon, sundialsvc4: i love to hear from you....

      regards
      perlbeginne1