Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!samsung!sdd.hp.com!wuarchive!psuvax1!psuvm!blekul11!ffaac09 From: FFAAC09@cc1.kuleuven.ac.be (Paul Bijnens) Newsgroups: comp.lang.perl Subject: format with tilde Message-ID: <91049.163743FFAAC09@cc1.kuleuven.ac.be> Date: 18 Feb 91 16:36:43 GMT Organization: K.U.Leuven - Academic Computing Center Lines: 95 I have a problem using single and double tilde in formats. I have a file with each line consisting of 20 fields separated by a tab. Most of the fields are blank, some are short and the rest is very long (up to 1000 chars or more). For printing this out, I wanted to use perl (what other program does not choke on such long lines?). A little skeleton of the program (which does also some other things) follows: -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- format = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Xword ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~ $Xvd ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $Xvd ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~ $Xhn ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $Xhn ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~ $Xdh ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $Xdh ------------------------------------ . while (<>) { reset 'X'; chop; split(/\t/); $Xword = @_[1]; if (@_[2] =~ /./) { $Xvd = "VD: " . @_[2]; } if (@_[3] =~ /./) { $Xhn = "HN: " . @_[3]; } if (@_[4] =~ /./) { $Xdh = "DH: " . @_[4]; } write; } -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- The format makes an "undented" (vs. "indented") paragraph of each field (except the first). If the field is blank, then is not printed. The output I expected would look like: -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- a cow VD: bla bla bla bla DH: blablalbalb blabla bla blab lab la lba bla bla bla bla bla ------------------------ a horse VD: blabla blabla bla blab lab la blalba blablabla balbla bla bla bla bal balba bla bla blba blabla blab lblablabal ------------------------- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- But it rather looks like: -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- a cow VD: bla bla bla bla DH: blablalbalb blabla bla blab lab la lba bla bla bla bla bla ------------------------ a horse VD: blabla blabla bla blab lab la blalba blablabla balbla bla bla bla bal balba bla bla blba blabla blab lblablabal ------------------------- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Instead of just repeating the line with two tildes, it repeats the pair of lines. What do I do wrong? Or isn't the format intended to be used for this purpose? Btw, in perl.4.0, beta release in lib/look.pl, we find: ;#Usage: &look(*FILEHANDLE,$key,$dict,$fold) and a little bit further: local(*FH,$key,$fold,$dict) = @_; ... If in doubt, look at the code... Polleke (Paul Bijnens) Linguistics dept., K. University Leuven, Belgium FFAAC09@cc1.kuleuven.ac.be