Automated acts of contrition for my fellow monks.. not so much poetry as pun...
#! /usr/system/bin/perl $punitive_cnt = 1000; $Sorry_line = "I will not write punny PERL in class!"; # Begin act of contrition open(FILEHANDLE,">>blackboard.txt"); while($punitive_cnt != 0){ print FILEHANDLE "$Sorry_line \n"; $punitive_cnt--; }; close(FILEHANDLE); # Show your contrition open(FILEHANDLE,"blackboard.txt"); while(<FILEHANDLE>){ print "line: $_\\n"; }

Replies are listed 'Best First'.
Re: Contriteness helper
by Mr. Muskrat (Canon) on Sep 26, 2002 at 21:23 UTC

    Okay, I'll play!

    #!/usr/bin/perl use warnings; # This didn't work, that's why I'm being punished use strict; # punishment should always be strict my $repetitions = 1000; # I've been really bad! # Start with a... open(BLACKBOARD, ">/dev/clean_slate"); for(my $line = 1; $line <= $repetitions; $line++) { print BLACKBOARD "$line: I must strive to do better in my studies.\n +"; } #close(BLACKBOARD); # whoever heard of closing a blackboard!?

Re: Contriteness helper
by sauoq (Abbot) on Sep 27, 2002 at 00:24 UTC

    Cute. I upvoted just for the use of "punitive" and "pun" together.

    One suggestion:

    while($punitive_cnt != 0){ print FILEHANDLE "$Sorry_line \n"; $punitive_cnt--; };

    might be better expressed as

    print FILEHANDLE "$Sorry_line \n" for (1..$punitive_cnt);

    -sauoq
    "My two cents aren't worth a dime.";
    
      Or even:
      print FILEHANDLE "$Sorry_line \n" x $punitive_cnt;

      :^) # Bow to the hyper smiley!
Re: Contriteness helper
by mojobozo (Monk) on Sep 27, 2002 at 16:38 UTC
    In the next to the last line, is the second back slash intentional? The output looks icky with it. In fact, the \n is not necessary either. And why the "Line:"? Personal preference? I like everything else, though! If I had a vote left, I'd probably give it.

    _____________________________________________________
    mojobozo
    word (wûrd)
    interj. Slang. Used to express approval or an affirmative response to
    something. Sometimes used with up. Source