Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Tagline Rotator

by cajun (Chaplain)
on Feb 09, 2001 at 11:34 UTC ( #57356=sourcecode: print w/replies, xml ) Need Help??
Category: E-Mail Programs
Author/Contact Info Mike Lewis cajun
cajun {at}
Description: Rotate those tired .signature taglines automatically. Put your taglines in the file $siginfile, one tagline per line. Setup a cron job to run the script every few minutes. Now you won't have to manually change your .signature line.

Output looks something like this:


Backup not found! A)bort, R)etry or P)anic?
10:25pm up 23:22, 6 users, load average: 1.04, 1.10, 1.14

#!/usr/bin/perl -w

use strict;

my $debug=0;
my $home='/home/users/somebody';
my $siginfile="$home/sig/sigfile";
my $tearline="  \n";
my $uptime=`uptime`;
my $outfile="$home/\.signature";

open(INFILE,"$siginfile") or die "Can't open $siginfile :$!";
open(OUTFILE,">$outfile") or die "Sorry, but I can't write to $outfile
+ :$!";

my %hash;

  # build a hash with $. as key and $_ as value

my $rand=rand($.);

my @body;

push (@body, $tearline);
push (@body, qq(  $hash{sprintf("%.0f", ($rand))}));
push (@body, $uptime);

if ($debug){
  print @body;
} else {
  print OUTFILE @body;

close INFILE;
close OUTFILE;
Replies are listed 'Best First'.
Re: Tagline Rotator
by vroom (Pope) on Feb 09, 2001 at 11:47 UTC
    I wrote one of these and changed my pine configuration so instead of piping an outgoing message to sendmail it ran the script to output my .signature and then passed it off to sendmail. CowboyNeal says mutt allows you to have a pipe in your sigfile settings which allows you to run the script every time you start composing a new message.

    vroom | Tim Vroom |
      Interesting thought. Thanks Tim. I also had thoughts about making it a daemon.
Re: Tagline Rotator
by Daddio (Chaplain) on May 29, 2001 at 07:46 UTC

    cajun, I think this is a great script. It's simple and straightforward.

    I would like to point out a couple of things that I think would help.

    First, I might recommend putting the open(OUTFILE,...) and close OUTFILE into the same else section as the print OUTFILE @body. There's no sense opening and closing a file if you don't need to in debug mode (and it will erase whatever is there if you are in debug mode - no sense doing that, either).

    Second, and more importantly, the sprintf("%.0f", ($rand) code may return a 0. To counter that, I would recommend these two changes:

    One, change

    my $rand=$rand($.);


    my $rand = 0; $rand = int rand($.) until $rand != 0;

    Two, change

    push (@body, qq(  $hash{sprintf("%.0f", ($rand))}));


    push (@body, qq(  $hash{$rand}));

    Hope this makes sense (it's been a long day :)!

    D a d d i o

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://57356]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2018-07-23 00:32 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (458 votes). Check out past polls.