[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Text -> HTML



Hi,

Tim A. Judd wrote:
> 
> I have about 220 text files, and each on them is something like this on
> the VERY FIRST LINE...
> 
> lockpicking master locks           by <WHOEVER>
> 
> what I need, is the "lockpicking master locks" and "by <WHOEVER>" into a
> scalar variable.. 

If you read your files line by line, you could try something
like this (maybe not the most elegant way ...):

  $flag=0;
  while(<FILE>) {
    chop;
    if($flag == 0) {
      ($a,$b) = /^(.*?)\s{2,}(.*?)$/;
      $flag=1;
    }
  }
  print "$a\n$b\n";

This assigns `lockpicking master locks' to $a and `by <WHOEVER>'
to $b (I'm not sure, if this fits your needs exactly, but that's the
way I understood your question ...  ;-)  ).


Bye, Eike

=====================================================================
 Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
            email : eike.grote@theo.phy.uni-bayreuth.de
         URL : http://btrzxa.fddi.uni-bayreuth.de/~btpa25/
=====================================================================