rkrebs@fantasy.dsd.es.com (Randall Krebs) (06/21/91)
While attempting to construct a white-space line folder (like "fold" except breaks occur on white space), I turned up the following unexpected behavior: format STDOUT = ~~^<<<<<<<<<<<< $cmd . $cmd = "fee -fi -fo -fug -i -smell -the -blood -of -a -perl-bug"; write; produces: fee -fi -fo - fug -i -smell the -blood - of -a -perl- bug My objection is in the treatment of dashes which are preceded by white space. Especially, the one preceding "the" in the command. system: Mips R3000 RISC/os 4.50 Perl 4.010 BTW: here is the white-space line folder so far. I would have shar-chived it, but I don't have a decent shar-chiver. Anybody want to direct me to a copy of a perl shar-chiver? #!/usr/local/bin/perl # # wfold: utility to fold on white space. # # usage: wfold [ -l max_length ] [ file ] ... # # example: wfold -l60 foo # to keep fold lines in file foo which are longer than 60 characters. $linemax = 78; while ($ARGV[0] =~ /^-/) { $_ = shift; if (/^-l(.*)/) { $linemax = ($1 ? 0 + $1 : 0 + shift); } else { die "usage: $0 [ -l max_length ] [ file ] ... \n"; } } $linemin = int($linemax / 2); $pgm = <<"ENDOFOO" while (<>) { 1 while s/\t/' ' x -((length(\$`) % 8) - 8)/e; s/\n?.{$linemin,$linemax} /\$&\n/g if length(\$_) > $linemax; print; } ENDOFOO ; eval $pgm; -- Randall S. Krebs | No offense is made where none is taken. (rkrebs@dsd.es.com) | Evans & Sutherland | - Old Japanese Proverb Salt Lake City, Utah |
rkrebs@fantasy.dsd.es.com (Randall Krebs) (06/21/91)
In article <1991Jun20.180323.20507@dsd.es.com>, in ignorance, I wrote: > > fee -fi -fo - > fug -i -smell > the -blood - > of -a -perl- > bug > > My objection is in the treatment of dashes which are preceded by > white space. Especially, the one preceding "the" in the command. OK. It has been brought to my attention that I can modify $: to stop the dashes at the end of the line. (Thanks, Raymond!) I am still curious where the dash before "the" went. Formatting shouldn't eat any characters, should it? After all, there is plenty of power in the language to snuff a character here and there if that is what I am trying to do. randall. -- Randall S. Krebs | No offense is made where none is taken. (rkrebs@dsd.es.com) | Evans & Sutherland | - Old Japanese Proverb Salt Lake City, Utah |
tchrist@convex.COM (Tom Christiansen) (06/21/91)
From the keyboard of rkrebs@fantasy.dsd.es.com (Randall Krebs): :While attempting to construct a white-space line folder (like "fold" :except breaks occur on white space), I turned up the following :unexpected behavior: : : format STDOUT = : ~~^<<<<<<<<<<<< : $cmd : . : $cmd = "fee -fi -fo -fug -i -smell -the -blood -of -a -perl-bug"; : write; : :produces: : : fee -fi -fo - : fug -i -smell : the -blood - : of -a -perl- : bug : :My objection is in the treatment of dashes which are preceded by :white space. Especially, the one preceding "the" in the command. That's because $: is set to "\n -" by default. Set it to "\n " if you don't want to count the dash. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."