Changeset b120bd3 for perl


Ignore:
Timestamp:
Sep 25, 2010, 5:58:38 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
c8d9f84
Parents:
118c919
git-author:
Kevin Riggle <kevinr@free-dissociation.com> (09/21/10 00:33:56)
git-committer:
Nelson Elhage <nelhage@mit.edu> (09/25/10 17:58:38)
Message:
add a random zsig function
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl.pm

    r675a998 rb120bd3  
    561561}
    562562
     563=head3 random_zephyr_signature
     564
     565Retrieve a random line from ~/.zsigs (except those beginning with '#')
     566and use it as the zephyr signature.
     567
     568=cut
     569
     570sub random_zephyr_signature
     571{
     572    my $zsigfile = "$ENV{'HOME'}/.zsigs";
     573    open my $file, '<', $zsigfile or die "Error opening file $zsigfile: $!";
     574    my @lines = grep !(/^#/ || /^\s*$/), <$file>;
     575    close $file;
     576    return '' if !@lines;
     577    my $zsig = "$lines[int(rand(scalar @lines))]";
     578    chomp $zsig;
     579    return $zsig;
     580}
     581
    563582# Stub for owl::startup / BarnOwl::startup, so it isn't bound to the
    564583# startup command. This may be redefined in a user's configfile.
Note: See TracChangeset for help on using the changeset viewer.