in reply to Signature rotation.

$/ = "%";

Why not "\n%\n"?

Oh, and just because I like Tie::File and strict, and dislike using /dev/urandom, here's an alternative implementation:

#!/usr/bin/perl -w use Tie::File; use IO::File; use Fcntl qw(O_RDONLY); use strict; chdir '/home/hagus'; tie my @fortunes, 'Tie::File', '.signatures.rot', mode => O_RDONLY, re +csep => "\n%\n"; IO::File->new('.signature', 'w')->print($fortunes[rand @fortunes]);

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re: Re: Signature rotation.
by hagus (Monk) on May 23, 2002 at 07:35 UTC
    Great! I like this.

    I've never used Tie before actually, so this is good sample code for me.

    Why not "\n%\n" ? Because I coded that in about 3 nanoseconds, and it didn't even occur to me. Maybe some C oriented portion of my brain baulked at using more than one character as a separator?!

    I think I had a reason for using /dev/urandom instead of rand. Who wants to remind me what it was? I've forgotten.

    --
    Ash OS durbatulk, ash OS gimbatul,
    Ash OS thrakatulk, agh burzum-ishi krimpatul!
    Uzg-Microsoft-ishi amal fauthut burguuli.