Changeset f816ff1 for perl


Ignore:
Timestamp:
Oct 14, 2009, 8:59:57 PM (15 years ago)
Author:
Karl Ramm <kcr@1ts.org>
Branches:
master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
76f0e19
Parents:
08e414a
git-author:
Karl Ramm <kcr@1ts.org> (10/14/09 20:58:55)
git-committer:
Karl Ramm <kcr@1ts.org> (10/14/09 20:59:57)
Message:
Add a zephyr randomizer as an alternative to default_zephyr_signature()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl.pm

    rdcc3f80 rf816ff1  
    447447}
    448448
     449=head3 random_zephyr_siganture
     450
     451Pick a random zephyr signature.
     452
     453=head3 reload_zephyr_signatures
     454
     455Reload the random zephyr signatures
     456
     457=head3 $random_zsig_separator
     458
     459What to split the zsigs on
     460
     461=cut
     462
     463our $random_zsig_separator='\n';
     464
     465{
     466  my $zsigs;
     467
     468  sub reload_zephyr_signatures {
     469    my $slurp;
     470
     471    srand;
     472
     473    if (open(ZSIGS, "$ENV{'HOME'}/.zsigs")) {
     474      {
     475        local $/ = undef;
     476        $slurp = <ZSIGS>;
     477      }
     478      $zsigs = [split(/$random_zsig_separator/, $slurp)];
     479    } else {
     480      $zsigs = [default_zephyr_signature()];
     481    }
     482  }
     483
     484  sub random_zephyr_signature {
     485    if (!defined($zsigs)) {
     486      reload_zephyr_signatures();
     487    }
     488    return $zsigs->[int(rand($#{$zsigs}))];
     489  }
     490}
     491
    449492# Stub for owl::startup / BarnOwl::startup, so it isn't bound to the
    450493# startup command. This may be redefined in a user's configfile.
Note: See TracChangeset for help on using the changeset viewer.