Hi

I've written a little program to analyze lines that
are longer than 70 characters, and if so, break at
position 70 (if it is whitespace), if not whitespace
(i.e. is in the middle of a word) it steps back to the
first whitespace and breaks there.

However, I think there is probably a better way to do
this.  Can someone either suggest an alternate route
or improve this snippet?

ps. if you do suggest something cryptic, please detail
for me, as I am still new!!! thanks

while(<F>) {
chomp;
      if (length $_ < 70){
      print F1 "$_\n";
      }
      
      else {

                split(//, $_);
                if ($_[69] eq " ") {
                s/^(.{69}) (.*)$/$1\n+ $2\n/;
                print F1;
                }
                elsif($_[69] ne " " && $_[68] eq " ")
{
                @_ = ();
                split(//, $_);
                s/^(.{68}) (.*)$/$1\n+ $2\n/;
                print F1 $_;
                }
                elsif($_[69] ne " " && $_[68] ne " "&&
$_[67] eq " ") {
                @_ = ();
                split(//, $_);
                s/^(.{67}) (.*)$/$1\n+ $2\n/;
                print F1 $_;
                }

.....

# this is the strategy to back up 30 spaces
eventually,
but I don't want to have 30 elsif statements, although
this works, it seems that a more experienced perl
programmer could write this with much less code...

__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to