A really short little ditty to take a file delimited by '%' characters (on lines by themselves) then randomly select an entry, then print it to the .signature file.

Literally taken straight from my ~/scripts directory, all still hardcoded. Pick it to pieces, but remember it's just a hack :)

First few lines of my .signature.rot file. Note the first line is blank, and there needn't be a trailing newline at the end:

Leo: (July 23 - Aug. 22) When driving through the desert, you should never stop and eat mysterious piles of birdseed, even if "FREE BIRDSEED" signs are stuck in them. % "Reality is that which, when you stop believing in it, doesn't go away". -- Philip K. Dick % So, Lone Starr, now you see that evil will always triumph, because good is dumb. -- Dark Helmet % Thank you for pressing the self-destruct button. This ship will self-destruct in three minutes. % Do you make up these questions, Mr. Holden, or do they write them down for you? % Yes, questions. Morphology, longevity, incept dates. % "Begun, this clone war has." Donate to the House With No Sentence Structure. Dedicated to assisting grammatically disadvantaged Jedi for over 900 years.
#!/usr/bin/perl use IO::File; $/ = "%"; open(FILE, "/home/hagus/.signature.rot"); while (<FILE>) { $tmp = $_; $tmp =~ s/%//g; push @a, $tmp; } close(FILE); my $fh = new IO::File("/dev/urandom", "r"); my $foo = $fh->read($value, 100); $fh->close(); my $num = unpack("S*", $value); my $index = $num % (@a + 0); open(FILE, ">/home/hagus/.signature"); print FILE $a[$index] . "\n"; close(FILE);

In reply to Signature rotation. by hagus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.