ircyrano

reenact cyrano de bergerac on an IRC server
git clone https://a3nm.net/git/ircyrano/
Log | Files | Refs | README

length.pl (517B)


      1 #!/usr/bin/perl -C7
      2 #
      3 # indent verse continuations with spaces
      4 
      5 use utf8;
      6 
      7 my $offset = 0;
      8 my $i;
      9 
     10 while (<>) {
     11   chop;
     12   if (/^([^ ]*)( [^\/].*)$/ and not /^ER/) {
     13     #for ($i = 0; $i < $offset; $i++) {
     14     #  print " ";
     15     #}
     16     #print "^\n";
     17     print "$1";
     18     for ($i = 0; $i < $offset - length($1) - 1; $i++) {
     19       print " ";
     20     }
     21     print "$2\n";
     22     $offset = length($1) + 1 if $offset == 0;
     23     $offset += length($2) - 4;
     24     $offset = 0 if not /\.\.\.$/;
     25   } else {
     26     print;
     27     print "\n";
     28   }
     29 }
     30