libfortune-perl-0.2/0042755000175000017500000000000007315763050014474 5ustar stratusstratuslibfortune-perl-0.2/dump_header0100555000175000017500000000144007315763024016670 0ustar stratusstratus#!/usr/bin/perl -w # # dump_header # # Quick hack to satisfy my curiosity about the header files # generated by strfile and used by fortune. (The Fortune # module is essentially a puffed-up, glorified version # of this, with the added ability to read actual fortune # files based on the offsets from the header file.) # # by Greg Ward, 1999/02/20 # # $Id: dump_header,v 1.1 1999/02/20 18:56:04 greg Exp $ # die "usage: dump_header header_file\n" unless @ARGV == 1; open (D, $ARGV[0]) || die "couldn't open $ARGV[0]: $!\n"; undef $/; $d = ; @d = unpack ("NNNNNaxxxN*", $d); print <read_header (); $num_fortunes = $ffile->num_fortunes (); $fortune = $ffile->read_fortune ($num); $fortune = $ffile->get_random_fortune (); # create header file from data file -- NOT IMPLEMENTED YET $ffile = new Fortune ($base_filename); $ffile->write_header (); # write to data file -- NOT IMPLEMENTED YET $ffile = new Fortune (">>$base_filename"); $ffile->write_fortune ($fortune); =head1 DESCRIPTION The C program is a small but important part of the Unix culture, and this module aims to provide support for its "fortune cookie" databases to Perl programmers. For efficiency, all versions of C rely on a binary header consisting mainly of offsets into the fortune file proper. Modern versions of fortune keep this header in a separate file, and this is the style adopted by the C module; the older style of munging the header and data into one large "compiled" file is not (currently) supported. Using the C module makes it trivial to write a simplified version of the C program: # trivial 'fortune' progam my $fortune_filename = $ARGV[0]; my $fortune_file = new Fortune ($fortune_filename); $fortune_file->read_header (); my $fortune = $fortune_file->get_random_fortune (); print $fortune; This can be compressed considerably: print new Fortune ($ARGV[0])->read_header()->get_random_fortune(); Of course, this doesn't provide all of C's interesting features, such as parallel databases of offensive fortunes, selection of long or short fortunes, dealing with multiple fortune files, etc. If you want C, use it -- but if you just want a simple Perl interface to its data files, the C module is for you. Currently, the C module does not support writing fortune databases. If it did, writing a simplified C (the program that processes a fortune database to create the header file) would also be trivial: # trivial (and hypothetical) 'strfile' program my $fortune_filename = @ARGV[0]; my $fortune_file = new Fortune ($fortune_filename); $fortune_file->write_header (); Note that the header filename is assumed to be just the name of the main fortune database, with C<".dat"> appended. You can supply an alternate header filename to the constructor, C, if you wish. =head1 METHODS =head2 Initialization/cleanup =over 4 =item new (FILE [, HEADER_FILE]) Opens a fortune cookie database. FILE is the name of the data file to open, and HEADER_FILE (if given) the name of the header file that contains (or will contain) meta-data about the fortune database. If HEADER_FILE is not given, it defaults to FILE with C<".dat"> appended. The data file is opened via C, which Cs if the file cannot be opened. The header file is I opened, whether you supply its filename or not -- after all, it might not exist yet. Rather, you must explicitly call C or C as appropriate. =cut sub new { my ($class, $filename, $header_filename) = @_; $class = ref $class || $class; my $self = bless { filename => $filename, header_filename => $header_filename || $filename . ".dat", }, $class; $self->open_file (); return $self; } sub DESTROY { my $self = shift; $self->close_file (); } =item open_file () Opens the fortune file whose name was supplied to the constructor. Dies on failure. =cut sub open_file { my $self = shift; my $file = new IO::File $self->{'filename'} or die "unable to open $self->{'filename'}: $!\n"; $self->{'file'} = $file; } =item close_file () Closes the fortune file if it's open; does nothing otherwise. =cut sub close_file { my $self = shift; $self->{'file'}->close () if defined $self->{'file'}; } =back =head2 Header functions (read and write) =over 4 =item read_header () Reads the header file associated with this fortune database. The name of the header file is determined by the constructor C: either it is based on the name of the data file, or supplied by the caller. If the header file does not exist, this function calls C automatically, which has the same effect as reading the header from a file. The header contains the following values, which are stored as attributes of the C object: =over 4 =item C version number =item C number of strings (fortunes) in the file =item C length of longest string in the file =item C length of shortest string in the file =item C bit field for flags (see strfile(1) man page) =item C character that delimits fortunes =back C is available via the C method; if you're interested in the others, you'll have to go grubbing through the C object, e.g.: $fortune_file = new Fortune ('fortunes'); $fortune_file->read_header (); $delim = $fortune_file->{'delim'}; C Cs if there are any problems reading the header file, e.g. if it seems to be corrupt or truncated. C returns the current C object, to allow for sneaky one-liners (see the examples above). =cut sub read_header { my ($self) = @_; my $filename = $self->{'header_filename'}; if (! -f $filename && -f $self->{'filename'}) { return $self->compute_header(); } my $hdr_file = new IO::File $filename or die "couldn't open $filename: $!\n|"; binmode ($hdr_file); # from the strfile(1) man page: # unsigned long str_version; /* version number */ # unsigned long str_numstr; /* # of strings in the file */ # unsigned long str_longlen; /* length of longest string */ # unsigned long str_shortlen; /* shortest string length */ # unsigned long str_flags; /* bit field for flags */ # char str_delim; /* delimiting character */ # that 'char' is padded out to a full word, so the header is 24 bytes my $header; read ($hdr_file, $header, 24) == 24 or die "failed to read full header\n"; @{$self}{qw(version numstr max_length min_length flags delim)} = unpack ("NNNNNaxxx", $header); my $expected_offsets = $self->{'numstr'} + 1; my $amount_data = 4 * $expected_offsets; my $data; read ($hdr_file, $data, $amount_data) == $amount_data or die "failed to read offsets for all fortunes\n"; my @offsets = unpack ("N*", $data); die sprintf ("found %d offsets (expected %d)\n", scalar @offsets, $expected_offsets) unless @offsets == $expected_offsets; $self->{'offsets'} = \@offsets; close ($hdr_file); return $self; } # read_header =item compute_header ([DELIM]) Reads the contents of the fortune file and computes the header information that would normally be found in a header (F<.dat>) file. This is useful if you maintain a file of fortunes by hand and do not have the corresponding data file. An optional delimiter argument may be passed to this function; if present, that delimiter will be used to separate entries in the fortune file. If not provided, the existing C attribute of the Fortune object will be used. If that is not defined, then a percent sign ("%") will be used. =cut sub compute_header { my ($self, $delim) = @_; $delim = $self->{'delim'} || '%' unless defined $delim; local $/ = $delim . "\n"; # read whole fortunes my $filename = $self->{'filename'}; my $file = new IO::File $filename or die "couldn't open $filename: $!\n"; my @offsets = (0); # start with offset of first fortune my $fortune = ''; my($min, $max); while (defined ($fortune = <$file>)) { chomp $fortune; my $len = length $fortune; if (!defined $min || $len < $min) { $min = $len } elsif (!defined $max || $len > $max) { $max = $len } push (@offsets, tell $file); } $self->{'version'} = 1; $self->{'numstr'} = $#offsets; $self->{'max_length'} = $max; $self->{'min_length'} = $min; $self->{'flags'} = 0; $self->{'delim'} = $delim; $self->{'offsets'} = \@offsets; } =item num_fortunes () Returns the number of fortunes found by C. =cut sub num_fortunes { my $self = shift; croak "header not read" unless defined $self->{'numstr'}; return $self->{'numstr'}; } =item write_header ([DELIM]) is not yet implemented. =cut =back =head2 Fortune input =over 4 =item get_fortune (NUM) Reads string number NUM from the open fortune file. NUM is zero-based, ie. it must be between 0 and C (inclusive). Cs if you haven't opened the file and read the header, or if NUM is out of range. (Opening the file is pretty hard to screw up, since it's taken care of for you by the constructor, but you have to read the header explicitly with C.) Returns the text of the fortune as a (possibly) multiline string. =cut sub read_fortune { my ($self, $num) = @_; croak "fortune file not open" unless defined $self->{'file'} and defined fileno ($self->{'file'}); croak "header file not read" unless defined $self->{'numstr'}; croak "invalid fortune number (max " . ($self->{'numstr'}-1) . ")" unless $num < $self->{'numstr'} && $num >= 0; my $start = $self->{'offsets'}[$num]; my $end = $self->{'offsets'}[$num+1]; my $length = $end - $start; # decrement length 2 bytes for most fortunes (to drop trailing "%\n"), # and none for the last one (keep trailing newline) my $delimlength = length $self->{'delim'} || 1; $length -= ($num == $self->{'numstr'}-1) ? 0 : ($delimlength+1); my $file = $self->{'file'}; my $fortune; seek ($file, $start, 0); read ($file, $fortune, $length) == $length or die "unable to read entire fortune\n"; return $fortune; } # get_fortune =item get_random_fortune () Picks a random fortune for you and reads it with C. =cut sub get_random_fortune { my ($self) = @_; croak "header file not read" unless defined $self->{'numstr'}; my $num = int (rand $self->{'numstr'}); return $self->read_fortune ($num); } =back =head2 Fortune output =over 4 =item write_fortune (FORTUNE) is not yet implemented. =back =cut 1; =head1 AUTHOR AND COPYRIGHT Written by Greg Ward Egward@python.netE, 20 February 1999. Copyright (c) 1999-2000 Gregory P. Ward. All rights reserved. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AVAILABILITY You can download the C module from my web page: http://starship.python.net/~gward/perl/ and it can also be found on CPAN. If you are using an operating system lacking a sufficient sense of humour to include C as part of its standard installation (most commercial Unices seem to be so afflicted), the Linux world has a solution: the C distribution. The latest version as of this writing is C, and the README file says you can find it at http://www.progsoc.uts.edu.au/~dbugger/hacks/hacks.html This is the C implementation on which the C module is based. libfortune-perl-0.2/Makefile.PL0100444000175000017500000000034207315763024016437 0ustar stratusstratus# $Id: Makefile.PL,v 1.1 1999/02/20 18:53:06 greg Exp $ use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Fortune', 'VERSION_FROM' => 'Fortune.pm', 'dist' => { COMPRESS => "gzip", SUFFIX => "gz" }, ); libfortune-perl-0.2/README0100444000175000017500000000231507315763024015347 0ustar stratusstratus Fortune.pm version 0.2 26 February 2000 Greg Ward Copyright (c) 1999-2000 Gregory P. Ward. All rights reserved. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module provides an interface to fortune cookie databases, as implemented by the fortune-mod-9708 distribution (which is widely used in the Linux world, and available with at least the Red Hat and Debian distributions). Currently, it is a read-only interface. If I ever need to a read-write interface, I suppose I'll write one; if *you* need one, feel free to write it and send me a patch! AVAILABILITY ------------ The latest version of this module will be available at: http://starship.python.net/~gward/perl/ If you need a full-blown fortune package, try fortune-mod, which should be available at: http://www.progsoc.uts.edu.au/~dbugger/hacks/hacks.html CREDITS ------- Thanks to Bill Ward for adding the code that allows reading a fortune file that doesn't have a header (index) file. $Id: README,v 1.2 2000/02/27 02:28:13 greg Exp $ libfortune-perl-0.2/t/0042755000175000017500000000000007315763024014740 5ustar stratusstratuslibfortune-perl-0.2/t/read.t0100444000175000017500000000164307315763024016035 0ustar stratusstratususe Fortune; # # Test the reading capabilities of the Fortune module. # # $Id: read.t,v 1.1 1999/02/20 18:56:59 greg Exp $ # my $i = 0; sub test { my $ok = shift; print (($ok ? 'ok ' : 'not ok ') . (++$i) . "\n"); } print "1..13\n"; test (my $ff = new Fortune ('t/test')); $ff->read_header (); test ($ff->{'numstr'} == 3 && $ff->num_fortunes() == 3); test ($ff->{'max_length'} == 54 && $ff->{'min_length'} == 13); test ($ff->{'delim'} eq '%'); @fortunes = ("This is\na test\nfortune file.\n", "Must have single-line as well as multi-line fortunes.\n", "And goodbye!\n"); test ($ff->read_fortune (0) eq $fortunes[0]); test ($ff->read_fortune (1) eq $fortunes[1]); test ($ff->read_fortune (2) eq $fortunes[2]); eval { $ff->read_fortune (3) }; test (defined $@ && $@ =~ /invalid fortune number/); for $i (1 .. 5) { $f = $ff->get_random_fortune (); test (grep ($_ eq $f, @fortunes) == 1); } libfortune-perl-0.2/t/test0100444000175000017500000000014407315763024015632 0ustar stratusstratusThis is a test fortune file. % Must have single-line as well as multi-line fortunes. % And goodbye! libfortune-perl-0.2/t/test20100444000175000017500000000062707315763024015722 0ustar stratusstratusEschew Obfuscation ** Time flies like an arrow; Fruit flies like a banana. ** A closed mouth gathers no foot. ** Time heals all wounds--if you don't keep picking off the scab. --Holly Ward ** Death lasts even longer than grade school and high school put together. --Matt Groening ** A ship carrying two tons of red paint and a ship carrying one ton of blue paint collide. All the passengers are marooned. libfortune-perl-0.2/t/test.dat0100644000175000017500000000005007315763024016377 0ustar stratusstratus6 %Wdlibfortune-perl-0.2/t/readnohdr.t0100444000175000017500000000264707315763024017075 0ustar stratusstratususe Fortune; # # Test the reading capabilities of the Fortune module in the # absence of a header (.dat) file. # # $Id: readnohdr.t,v 1.3 2000/02/27 02:23:04 greg Exp $ # my $i = 0; sub test { my $ok = shift; print (($ok ? 'ok ' : 'not ok ') . (++$i) . "\n"); } print "1..14\n"; test (my $ff = new Fortune ('t/test2')); $ff->compute_header ('**'); test ($ff->{'numstr'} == 6 && $ff->num_fortunes() == 6); test ($ff->{'max_length'} == 123 && $ff->{'min_length'} == 19); test ($ff->{'delim'} eq '**'); @fortunes = ("Eschew Obfuscation\n", "Time flies like an arrow; Fruit flies like a banana.\n", "A closed mouth gathers no foot.\n", "Time heals all wounds--if you don't keep picking off the scab.\n--Holly Ward\n", "Death lasts even longer than grade school and high school put\ntogether. --Matt Groening\n", "A ship carrying two tons of red paint and a ship carrying one ton\nof blue paint collide. All the passengers are marooned.\n"); @lengths = sort {$a <=> $b} (map (length, @fortunes)); test ($ff->{'max_length'} == $lengths[-1] && $ff->{'min_length'} == $lengths[0]); test ($ff->read_fortune (0) eq $fortunes[0]); test ($ff->read_fortune (1) eq $fortunes[1]); test ($ff->read_fortune (5) eq $fortunes[5]); eval { $ff->read_fortune (6) }; test (defined $@ && $@ =~ /invalid fortune number/); for $i (1 .. 5) { $f = $ff->get_random_fortune (); test (grep ($_ eq $f, @fortunes) == 1); } libfortune-perl-0.2/blib/0042755000175000017500000000000007315763025015406 5ustar stratusstratuslibfortune-perl-0.2/blib/lib/0040755000175000017500000000000007315763025016152 5ustar stratusstratuslibfortune-perl-0.2/blib/lib/.exists0100644000175000017500000000000007315763024017454 0ustar stratusstratuslibfortune-perl-0.2/blib/lib/auto/0040755000175000017500000000000007315763025017122 5ustar stratusstratuslibfortune-perl-0.2/blib/lib/auto/Fortune/0040755000175000017500000000000007315763025020544 5ustar stratusstratuslibfortune-perl-0.2/blib/lib/auto/Fortune/.exists0100644000175000017500000000000007315763025022047 0ustar stratusstratuslibfortune-perl-0.2/blib/lib/Fortune.pm0100444000175000017500000002670007315763025020132 0ustar stratusstratus# # Fortune.pm # # interface to fortune cookie databases # # by Greg Ward, 1999/02/20 # # $Id: Fortune.pm,v 1.4 2000/02/27 02:22:31 greg Exp $ # package Fortune; require 5.004; use strict; use Carp; use IO::File; $Fortune::VERSION = '0.2'; =head1 NAME Fortune - read and write fortune (strfile) databases =head1 SYNOPSIS # input $ffile = new Fortune ($base_filename); $ffile->read_header (); $num_fortunes = $ffile->num_fortunes (); $fortune = $ffile->read_fortune ($num); $fortune = $ffile->get_random_fortune (); # create header file from data file -- NOT IMPLEMENTED YET $ffile = new Fortune ($base_filename); $ffile->write_header (); # write to data file -- NOT IMPLEMENTED YET $ffile = new Fortune (">>$base_filename"); $ffile->write_fortune ($fortune); =head1 DESCRIPTION The C program is a small but important part of the Unix culture, and this module aims to provide support for its "fortune cookie" databases to Perl programmers. For efficiency, all versions of C rely on a binary header consisting mainly of offsets into the fortune file proper. Modern versions of fortune keep this header in a separate file, and this is the style adopted by the C module; the older style of munging the header and data into one large "compiled" file is not (currently) supported. Using the C module makes it trivial to write a simplified version of the C program: # trivial 'fortune' progam my $fortune_filename = $ARGV[0]; my $fortune_file = new Fortune ($fortune_filename); $fortune_file->read_header (); my $fortune = $fortune_file->get_random_fortune (); print $fortune; This can be compressed considerably: print new Fortune ($ARGV[0])->read_header()->get_random_fortune(); Of course, this doesn't provide all of C's interesting features, such as parallel databases of offensive fortunes, selection of long or short fortunes, dealing with multiple fortune files, etc. If you want C, use it -- but if you just want a simple Perl interface to its data files, the C module is for you. Currently, the C module does not support writing fortune databases. If it did, writing a simplified C (the program that processes a fortune database to create the header file) would also be trivial: # trivial (and hypothetical) 'strfile' program my $fortune_filename = @ARGV[0]; my $fortune_file = new Fortune ($fortune_filename); $fortune_file->write_header (); Note that the header filename is assumed to be just the name of the main fortune database, with C<".dat"> appended. You can supply an alternate header filename to the constructor, C, if you wish. =head1 METHODS =head2 Initialization/cleanup =over 4 =item new (FILE [, HEADER_FILE]) Opens a fortune cookie database. FILE is the name of the data file to open, and HEADER_FILE (if given) the name of the header file that contains (or will contain) meta-data about the fortune database. If HEADER_FILE is not given, it defaults to FILE with C<".dat"> appended. The data file is opened via C, which Cs if the file cannot be opened. The header file is I opened, whether you supply its filename or not -- after all, it might not exist yet. Rather, you must explicitly call C or C as appropriate. =cut sub new { my ($class, $filename, $header_filename) = @_; $class = ref $class || $class; my $self = bless { filename => $filename, header_filename => $header_filename || $filename . ".dat", }, $class; $self->open_file (); return $self; } sub DESTROY { my $self = shift; $self->close_file (); } =item open_file () Opens the fortune file whose name was supplied to the constructor. Dies on failure. =cut sub open_file { my $self = shift; my $file = new IO::File $self->{'filename'} or die "unable to open $self->{'filename'}: $!\n"; $self->{'file'} = $file; } =item close_file () Closes the fortune file if it's open; does nothing otherwise. =cut sub close_file { my $self = shift; $self->{'file'}->close () if defined $self->{'file'}; } =back =head2 Header functions (read and write) =over 4 =item read_header () Reads the header file associated with this fortune database. The name of the header file is determined by the constructor C: either it is based on the name of the data file, or supplied by the caller. If the header file does not exist, this function calls C automatically, which has the same effect as reading the header from a file. The header contains the following values, which are stored as attributes of the C object: =over 4 =item C version number =item C number of strings (fortunes) in the file =item C length of longest string in the file =item C length of shortest string in the file =item C bit field for flags (see strfile(1) man page) =item C character that delimits fortunes =back C is available via the C method; if you're interested in the others, you'll have to go grubbing through the C object, e.g.: $fortune_file = new Fortune ('fortunes'); $fortune_file->read_header (); $delim = $fortune_file->{'delim'}; C Cs if there are any problems reading the header file, e.g. if it seems to be corrupt or truncated. C returns the current C object, to allow for sneaky one-liners (see the examples above). =cut sub read_header { my ($self) = @_; my $filename = $self->{'header_filename'}; if (! -f $filename && -f $self->{'filename'}) { return $self->compute_header(); } my $hdr_file = new IO::File $filename or die "couldn't open $filename: $!\n|"; binmode ($hdr_file); # from the strfile(1) man page: # unsigned long str_version; /* version number */ # unsigned long str_numstr; /* # of strings in the file */ # unsigned long str_longlen; /* length of longest string */ # unsigned long str_shortlen; /* shortest string length */ # unsigned long str_flags; /* bit field for flags */ # char str_delim; /* delimiting character */ # that 'char' is padded out to a full word, so the header is 24 bytes my $header; read ($hdr_file, $header, 24) == 24 or die "failed to read full header\n"; @{$self}{qw(version numstr max_length min_length flags delim)} = unpack ("NNNNNaxxx", $header); my $expected_offsets = $self->{'numstr'} + 1; my $amount_data = 4 * $expected_offsets; my $data; read ($hdr_file, $data, $amount_data) == $amount_data or die "failed to read offsets for all fortunes\n"; my @offsets = unpack ("N*", $data); die sprintf ("found %d offsets (expected %d)\n", scalar @offsets, $expected_offsets) unless @offsets == $expected_offsets; $self->{'offsets'} = \@offsets; close ($hdr_file); return $self; } # read_header =item compute_header ([DELIM]) Reads the contents of the fortune file and computes the header information that would normally be found in a header (F<.dat>) file. This is useful if you maintain a file of fortunes by hand and do not have the corresponding data file. An optional delimiter argument may be passed to this function; if present, that delimiter will be used to separate entries in the fortune file. If not provided, the existing C attribute of the Fortune object will be used. If that is not defined, then a percent sign ("%") will be used. =cut sub compute_header { my ($self, $delim) = @_; $delim = $self->{'delim'} || '%' unless defined $delim; local $/ = $delim . "\n"; # read whole fortunes my $filename = $self->{'filename'}; my $file = new IO::File $filename or die "couldn't open $filename: $!\n"; my @offsets = (0); # start with offset of first fortune my $fortune = ''; my($min, $max); while (defined ($fortune = <$file>)) { chomp $fortune; my $len = length $fortune; if (!defined $min || $len < $min) { $min = $len } elsif (!defined $max || $len > $max) { $max = $len } push (@offsets, tell $file); } $self->{'version'} = 1; $self->{'numstr'} = $#offsets; $self->{'max_length'} = $max; $self->{'min_length'} = $min; $self->{'flags'} = 0; $self->{'delim'} = $delim; $self->{'offsets'} = \@offsets; } =item num_fortunes () Returns the number of fortunes found by C. =cut sub num_fortunes { my $self = shift; croak "header not read" unless defined $self->{'numstr'}; return $self->{'numstr'}; } =item write_header ([DELIM]) is not yet implemented. =cut =back =head2 Fortune input =over 4 =item get_fortune (NUM) Reads string number NUM from the open fortune file. NUM is zero-based, ie. it must be between 0 and C (inclusive). Cs if you haven't opened the file and read the header, or if NUM is out of range. (Opening the file is pretty hard to screw up, since it's taken care of for you by the constructor, but you have to read the header explicitly with C.) Returns the text of the fortune as a (possibly) multiline string. =cut sub read_fortune { my ($self, $num) = @_; croak "fortune file not open" unless defined $self->{'file'} and defined fileno ($self->{'file'}); croak "header file not read" unless defined $self->{'numstr'}; croak "invalid fortune number (max " . ($self->{'numstr'}-1) . ")" unless $num < $self->{'numstr'} && $num >= 0; my $start = $self->{'offsets'}[$num]; my $end = $self->{'offsets'}[$num+1]; my $length = $end - $start; # decrement length 2 bytes for most fortunes (to drop trailing "%\n"), # and none for the last one (keep trailing newline) my $delimlength = length $self->{'delim'} || 1; $length -= ($num == $self->{'numstr'}-1) ? 0 : ($delimlength+1); my $file = $self->{'file'}; my $fortune; seek ($file, $start, 0); read ($file, $fortune, $length) == $length or die "unable to read entire fortune\n"; return $fortune; } # get_fortune =item get_random_fortune () Picks a random fortune for you and reads it with C. =cut sub get_random_fortune { my ($self) = @_; croak "header file not read" unless defined $self->{'numstr'}; my $num = int (rand $self->{'numstr'}); return $self->read_fortune ($num); } =back =head2 Fortune output =over 4 =item write_fortune (FORTUNE) is not yet implemented. =back =cut 1; =head1 AUTHOR AND COPYRIGHT Written by Greg Ward Egward@python.netE, 20 February 1999. Copyright (c) 1999-2000 Gregory P. Ward. All rights reserved. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AVAILABILITY You can download the C module from my web page: http://starship.python.net/~gward/perl/ and it can also be found on CPAN. If you are using an operating system lacking a sufficient sense of humour to include C as part of its standard installation (most commercial Unices seem to be so afflicted), the Linux world has a solution: the C distribution. The latest version as of this writing is C, and the README file says you can find it at http://www.progsoc.uts.edu.au/~dbugger/hacks/hacks.html This is the C implementation on which the C module is based. libfortune-perl-0.2/blib/arch/0042755000175000017500000000000007315763025016323 5ustar stratusstratuslibfortune-perl-0.2/blib/arch/auto/0042755000175000017500000000000007315763025017273 5ustar stratusstratuslibfortune-perl-0.2/blib/arch/auto/Fortune/0040755000175000017500000000000007315763025020713 5ustar stratusstratuslibfortune-perl-0.2/blib/arch/auto/Fortune/.exists0100644000175000017500000000000007315763025022216 0ustar stratusstratuslibfortune-perl-0.2/blib/man3/0040755000175000017500000000000007315763025016242 5ustar stratusstratuslibfortune-perl-0.2/blib/man3/.exists0100644000175000017500000000000007315763025017545 0ustar stratusstratuslibfortune-perl-0.2/blib/man3/Fortune.3pm0100644000175000017500000003073507315763025020312 0ustar stratusstratus.\" Automatically generated by Pod::Man version 1.16 .\" Mon Jun 25 14:13:03 2001 .\" .\" Standard preamble: .\" ====================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Ip \" List item .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used .\" to do unbreakable dashes and therefore won't be available. \*(C` and .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<> .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and .\" index entries marked with X<> in POD. Of course, you'll have to process .\" the output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it .\" makes way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. .bd B 3 . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ====================================================================== .\" .IX Title "Fortune 3" .TH Fortune 3 "perl v5.6.1" "2000-02-26" "User Contributed Perl Documentation" .UC .SH "NAME" Fortune \- read and write fortune (strfile) databases .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& # input \& $ffile = new Fortune ($base_filename); \& $ffile->read_header (); \& $num_fortunes = $ffile->num_fortunes (); \& $fortune = $ffile->read_fortune ($num); \& $fortune = $ffile->get_random_fortune (); .Ve .Vb 3 \& # create header file from data file -- NOT IMPLEMENTED YET \& $ffile = new Fortune ($base_filename); \& $ffile->write_header (); .Ve .Vb 3 \& # write to data file -- NOT IMPLEMENTED YET \& $ffile = new Fortune (">>$base_filename"); \& $ffile->write_fortune ($fortune); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`fortune\*(C'\fR program is a small but important part of the Unix culture, and this module aims to provide support for its \*(L"fortune cookie\*(R" databases to Perl programmers. For efficiency, all versions of \&\f(CW\*(C`fortune\*(C'\fR rely on a binary header consisting mainly of offsets into the fortune file proper. Modern versions of fortune keep this header in a separate file, and this is the style adopted by the \f(CW\*(C`Fortune\*(C'\fR module; the older style of munging the header and data into one large \*(L"compiled\*(R" file is not (currently) supported. .PP Using the \f(CW\*(C`Fortune\*(C'\fR module makes it trivial to write a simplified version of the \f(CW\*(C`fortune\*(C'\fR program: .PP .Vb 6 \& # trivial 'fortune' progam \& my $fortune_filename = $ARGV[0]; \& my $fortune_file = new Fortune ($fortune_filename); \& $fortune_file->read_header (); \& my $fortune = $fortune_file->get_random_fortune (); \& print $fortune; .Ve This can be compressed considerably: .PP .Vb 1 \& print new Fortune ($ARGV[0])->read_header()->get_random_fortune(); .Ve Of course, this doesn't provide all of \f(CW\*(C`fortune\*(C'\fR's interesting features, such as parallel databases of offensive fortunes, selection of long or short fortunes, dealing with multiple fortune files, etc. If you want \f(CW\*(C`fortune\*(C'\fR, use it \*(-- but if you just want a simple Perl interface to its data files, the \f(CW\*(C`Fortune\*(C'\fR module is for you. .PP Currently, the \f(CW\*(C`Fortune\*(C'\fR module does not support writing fortune databases. If it did, writing a simplified \f(CW\*(C`strfile\*(C'\fR (the program that processes a fortune database to create the header file) would also be trivial: .PP .Vb 4 \& # trivial (and hypothetical) 'strfile' program \& my $fortune_filename = @ARGV[0]; \& my $fortune_file = new Fortune ($fortune_filename); \& $fortune_file->write_header (); .Ve Note that the header filename is assumed to be just the name of the main fortune database, with \f(CW\*(C`".dat"\*(C'\fR appended. You can supply an alternate header filename to the constructor, \f(CW\*(C`new()\*(C'\fR, if you wish. .SH "METHODS" .IX Header "METHODS" .Sh "Initialization/cleanup" .IX Subsection "Initialization/cleanup" .Ip "new (\s-1FILE\s0 [, \s-1HEADER_FILE\s0])" 4 .IX Item "new (FILE [, HEADER_FILE])" Opens a fortune cookie database. \s-1FILE\s0 is the name of the data file to open, and \s-1HEADER_FILE\s0 (if given) the name of the header file that contains (or will contain) meta-data about the fortune database. If \&\s-1HEADER_FILE\s0 is not given, it defaults to \s-1FILE\s0 with \f(CW\*(C`".dat"\*(C'\fR appended. .Sp The data file is opened via \f(CW\*(C`open_file()\*(C'\fR, which \f(CW\*(C`die\*(C'\fRs if the file cannot be opened. The header file is \fInot\fR opened, whether you supply its filename or not \*(-- after all, it might not exist yet. Rather, you must explicitly call \f(CW\*(C`read_header()\*(C'\fR or \f(CW\*(C`write_header()\*(C'\fR as appropriate. .Ip "open_file ()" 4 .IX Item "open_file ()" Opens the fortune file whose name was supplied to the constructor. Dies on failure. .Ip "close_file ()" 4 .IX Item "close_file ()" Closes the fortune file if it's open; does nothing otherwise. .Sh "Header functions (read and write)" .IX Subsection "Header functions (read and write)" .Ip "read_header ()" 4 .IX Item "read_header ()" Reads the header file associated with this fortune database. The name of the header file is determined by the constructor \f(CW\*(C`new\*(C'\fR: either it is based on the name of the data file, or supplied by the caller. .Sp If the header file does not exist, this function calls \f(CW\*(C`compute_header()\*(C'\fR automatically, which has the same effect as reading the header from a file. .Sp The header contains the following values, which are stored as attributes of the \f(CW\*(C`Fortune\*(C'\fR object: .RS 4 .if n .Ip "\f(CW""""version""""\fR" 4 .el .Ip "\f(CWversion\fR" 4 .IX Item "version" version number .if n .Ip "\f(CW""""numstr""""\fR" 4 .el .Ip "\f(CWnumstr\fR" 4 .IX Item "numstr" number of strings (fortunes) in the file .if n .Ip "\f(CW""""max_length""""\fR" 4 .el .Ip "\f(CWmax_length\fR" 4 .IX Item "max_length" length of longest string in the file .if n .Ip "\f(CW""""min_length""""\fR" 4 .el .Ip "\f(CWmin_length\fR" 4 .IX Item "min_length" length of shortest string in the file .if n .Ip "\f(CW""""flags""""\fR" 4 .el .Ip "\f(CWflags\fR" 4 .IX Item "flags" bit field for flags (see \fIstrfile\fR\|(1) man page) .if n .Ip "\f(CW""""delim""""\fR" 4 .el .Ip "\f(CWdelim\fR" 4 .IX Item "delim" character that delimits fortunes .RE .RS 4 .Sp \&\f(CW\*(C`numstr\*(C'\fR is available via the \f(CW\*(C`num_fortunes()\*(C'\fR method; if you're interested in the others, you'll have to go grubbing through the \&\f(CW\*(C`Fortune\*(C'\fR object, e.g.: .Sp .Vb 3 \& $fortune_file = new Fortune ('fortunes'); \& $fortune_file->read_header (); \& $delim = $fortune_file->{'delim'}; .Ve \&\f(CW\*(C`read_header()\*(C'\fR \f(CW\*(C`die\*(C'\fRs if there are any problems reading the header file, e.g. if it seems to be corrupt or truncated. .Sp \&\f(CW\*(C`read_header()\*(C'\fR returns the current \f(CW\*(C`Fortune\*(C'\fR object, to allow for sneaky one-liners (see the examples above). .RE .Ip "compute_header ([\s-1DELIM\s0])" 4 .IX Item "compute_header ([DELIM])" Reads the contents of the fortune file and computes the header information that would normally be found in a header (\fI.dat\fR) file. This is useful if you maintain a file of fortunes by hand and do not have the corresponding data file. .Sp An optional delimiter argument may be passed to this function; if present, that delimiter will be used to separate entries in the fortune file. If not provided, the existing \f(CW\*(C`delim\*(C'\fR attribute of the Fortune object will be used. If that is not defined, then a percent sign (\*(L"%\*(R") will be used. .Ip "num_fortunes ()" 4 .IX Item "num_fortunes ()" Returns the number of fortunes found by \f(CW\*(C`read_header()\*(C'\fR. .Ip "write_header ([\s-1DELIM\s0])" 4 .IX Item "write_header ([DELIM])" is not yet implemented. .Sh "Fortune input" .IX Subsection "Fortune input" .Ip "get_fortune (\s-1NUM\s0)" 4 .IX Item "get_fortune (NUM)" Reads string number \s-1NUM\s0 from the open fortune file. \s-1NUM\s0 is zero-based, ie. it must be between 0 and \f(CW\*(C`num_fortunes()\-1\*(C'\fR (inclusive). \f(CW\*(C`croak\*(C'\fRs if you haven't opened the file and read the header, or if \s-1NUM\s0 is out of range. (Opening the file is pretty hard to screw up, since it's taken care of for you by the constructor, but you have to read the header explicitly with \&\f(CW\*(C`read_header()\*(C'\fR.) Returns the text of the fortune as a (possibly) multiline string. .Ip "get_random_fortune ()" 4 .IX Item "get_random_fortune ()" Picks a random fortune for you and reads it with \f(CW\*(C`read_fortune()\*(C'\fR. .Sh "Fortune output" .IX Subsection "Fortune output" .Ip "write_fortune (\s-1FORTUNE\s0)" 4 .IX Item "write_fortune (FORTUNE)" is not yet implemented. .SH "AUTHOR AND COPYRIGHT" .IX Header "AUTHOR AND COPYRIGHT" Written by Greg Ward , 20 February 1999. .PP Copyright (c) 1999\-2000 Gregory P. Ward. All rights reserved. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "AVAILABILITY" .IX Header "AVAILABILITY" You can download the \f(CW\*(C`Fortune\*(C'\fR module from my web page: .PP .Vb 1 \& http://starship.python.net/~gward/perl/ .Ve and it can also be found on \s-1CPAN\s0. .PP If you are using an operating system lacking a sufficient sense of humour to include \f(CW\*(C`fortune\*(C'\fR as part of its standard installation (most commercial Unices seem to be so afflicted), the Linux world has a solution: the \f(CW\*(C`fortune\-mod\*(C'\fR distribution. The latest version as of this writing is \f(CW\*(C`fortune\-mod\-9708\*(C'\fR, and the \s-1README\s0 file says you can find it at .PP .Vb 1 \& http://www.progsoc.uts.edu.au/~dbugger/hacks/hacks.html .Ve This is the \f(CW\*(C`fortune\*(C'\fR implementation on which the \f(CW\*(C`Fortune\*(C'\fR module is based. libfortune-perl-0.2/Makefile0100644000175000017500000004417307315763025016142 0ustar stratusstratus# This Makefile is for the Fortune extension to perl. # # It was generated automatically by MakeMaker version # 5.45 (Revision: 1.222) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: (q[INSTALLDIRS=perl]) # # MakeMaker Parameters: # NAME => q[Fortune] # VERSION_FROM => q[Fortune.pm] # dist => { COMPRESS=>q[gzip], SUFFIX=>q[gz] } # --- MakeMaker post_initialize section: # --- MakeMaker const_config section: # These definitions are from config.sh (via /usr/lib/perl/5.6.1/Config.pm) # They may have been overridden via Makefile.PL or on the command line AR = ar CC = cc CCCDLFLAGS = -fPIC CCDLFLAGS = -rdynamic DLEXT = so DLSRC = dl_dlopen.xs LD = cc LDDLFLAGS = -shared -L/usr/local/lib LDFLAGS = -L/usr/local/lib LIBC = /lib/libc-2.2.3.so LIB_EXT = .a OBJ_EXT = .o OSNAME = linux OSVERS = 2.4.5-ac9 RANLIB = : SO = so EXE_EXT = FULL_AR = /usr/bin/ar # --- MakeMaker constants section: AR_STATIC_ARGS = cr NAME = Fortune DISTNAME = Fortune NAME_SYM = Fortune VERSION = 0.2 VERSION_SYM = 0_2 XS_VERSION = 0.2 INST_BIN = blib/bin INST_EXE = blib/script INST_LIB = blib/lib INST_ARCHLIB = blib/arch INST_SCRIPT = blib/script PREFIX = /usr SITEPREFIX = $(PREFIX)/local INSTALLDIRS = perl INSTALLPRIVLIB = $(PREFIX)/share/perl/5.6.1 INSTALLARCHLIB = $(PREFIX)/lib/perl/5.6.1 INSTALLSITELIB = $(SITEPREFIX)/share/perl/5.6.1 INSTALLSITEARCH = $(SITEPREFIX)/lib/perl/5.6.1 INSTALLVENDORLIB = $(PREFIX)/share/perl5 INSTALLVENDORARCH = $(PREFIX)/lib/perl5 INSTALLBIN = $(PREFIX)/bin INSTALLSCRIPT = $(PREFIX)/bin INSTALLSITEBIN = $(SITEPREFIX)/bin PERL_LIB = /usr/share/perl/5.6.1 PERL_ARCHLIB = /usr/lib/perl/5.6.1 SITELIBEXP = /usr/local/share/perl/5.6.1 SITEARCHEXP = /usr/local/lib/perl/5.6.1 LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile MAKE_APERL_FILE = Makefile.aperl PERLMAINCC = $(CC) PERL_INC = /usr/lib/perl/5.6.1/CORE PERL = /usr/bin/perl FULLPERL = /usr/bin/perl FULL_AR = /usr/bin/ar VERSION_MACRO = VERSION DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc MAKEMAKER = /usr/share/perl/5.6.1/ExtUtils/MakeMaker.pm MM_VERSION = 5.45 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!! # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. FULLEXT = Fortune BASEEXT = Fortune DLBASE = $(BASEEXT) VERSION_FROM = Fortune.pm OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic # Handy lists of source code files: XS_FILES= C_FILES = O_FILES = H_FILES = HTMLLIBPODS = HTMLSCRIPTPODS = MAN1PODS = MAN3PODS = Fortune.pm HTMLEXT = html INST_MAN1DIR = blib/man1 INSTALLMAN1DIR = $(PREFIX)/share/man/man1 INSTALLSITEMAN1DIR = $(SITEPREFIX)/man/man1 MAN1EXT = 1p INST_MAN3DIR = blib/man3 INSTALLMAN3DIR = $(PREFIX)/share/man/man3 INSTALLSITEMAN3DIR = $(SITEPREFIX)/man/man3 MAN3EXT = 3pm PERM_RW = 644 PERM_RWX = 755 # work around a famous dec-osf make(1) feature(?): makemakerdflt: all .SUFFIXES: .xs .c .C .cpp .cxx .cc $(OBJ_EXT) # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that # some make implementations will delete the Makefile when we rebuild it. Because # we call false(1) when we rebuild it. So make(1) is not completely wrong when it # does so. Our milage may vary. # .PRECIOUS: Makefile # seems to be not necessary anymore .PHONY: all config static dynamic test linkext manifest # Where is the Config information that we are using/depend on CONFIGDEP = $(PERL_ARCHLIB)/Config.pm $(PERL_INC)/config.h # Where to put things: INST_LIBDIR = $(INST_LIB) INST_ARCHLIBDIR = $(INST_ARCHLIB) INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) INST_STATIC = INST_DYNAMIC = INST_BOOT = EXPORT_LIST = PERL_ARCHIVE = PERL_ARCHIVE_AFTER = TO_INST_PM = Fortune.pm PM_TO_BLIB = Fortune.pm \ $(INST_LIBDIR)/Fortune.pm # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;' # --- MakeMaker tool_xsubpp section: # --- MakeMaker tools_other section: SHELL = /bin/sh CHMOD = chmod CP = cp LD = cc MV = mv NOOP = $(SHELL) -c true RM_F = rm -f RM_RF = rm -rf TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 # The following is a portable way to say mkdir -p # To see which directories are created, change the if 0 to if 1 MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath # This helps us to minimize the effect of the .exists files A yet # better solution would be to have a stable file in the perl # distribution with a timestamp of zero. But this solution doesn't # need any changes to the core distribution and works with older perls EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime # Here we warn users that an old packlist file was found somewhere, # and that they should call some uninstall routine WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \ -e 'print "WARNING: I have found an old package in\n";' \ -e 'print "\t$$ARGV[0].\n";' \ -e 'print "Please make sure the two installations are not conflicting\n";' UNINST=0 VERBINST=0 MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \ -e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');" DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \ -e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", $$arg=shift, "|", $$arg, ">";' \ -e 'print "=over 4";' \ -e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \ -e 'print "=back";' UNINSTALL = $(PERL) -MExtUtils::Install \ -e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \ -e 'print " packlist above carefully.\n There may be errors. Remove the";' \ -e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"' # --- MakeMaker dist section: DISTVNAME = $(DISTNAME)-$(VERSION) TAR = tar TARFLAGS = cvf ZIP = zip ZIPFLAGS = -r COMPRESS = gzip SUFFIX = gz SHAR = shar PREOP = @$(NOOP) POSTOP = @$(NOOP) TO_UNIX = @$(NOOP) CI = ci -u RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist # --- MakeMaker macro section: # --- MakeMaker depend section: # --- MakeMaker cflags section: # --- MakeMaker const_loadlibs section: # --- MakeMaker const_cccmd section: # --- MakeMaker post_constants section: # --- MakeMaker pasthru section: PASTHRU = LIB="$(LIB)"\ LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ PREFIX="$(PREFIX)"\ OPTIMIZE="$(OPTIMIZE)" # --- MakeMaker c_o section: # --- MakeMaker xs_c section: # --- MakeMaker xs_o section: # --- MakeMaker top_targets section: #all :: config $(INST_PM) subdirs linkext manifypods all :: pure_all htmlifypods manifypods @$(NOOP) pure_all :: config pm_to_blib subdirs linkext @$(NOOP) subdirs :: $(MYEXTLIB) @$(NOOP) config :: Makefile $(INST_LIBDIR)/.exists @$(NOOP) config :: $(INST_ARCHAUTODIR)/.exists @$(NOOP) config :: $(INST_AUTODIR)/.exists @$(NOOP) $(INST_AUTODIR)/.exists :: /usr/lib/perl/5.6.1/CORE/perl.h @$(MKPATH) $(INST_AUTODIR) @$(EQUALIZE_TIMESTAMP) /usr/lib/perl/5.6.1/CORE/perl.h $(INST_AUTODIR)/.exists -@$(CHMOD) $(PERM_RWX) $(INST_AUTODIR) $(INST_LIBDIR)/.exists :: /usr/lib/perl/5.6.1/CORE/perl.h @$(MKPATH) $(INST_LIBDIR) @$(EQUALIZE_TIMESTAMP) /usr/lib/perl/5.6.1/CORE/perl.h $(INST_LIBDIR)/.exists -@$(CHMOD) $(PERM_RWX) $(INST_LIBDIR) $(INST_ARCHAUTODIR)/.exists :: /usr/lib/perl/5.6.1/CORE/perl.h @$(MKPATH) $(INST_ARCHAUTODIR) @$(EQUALIZE_TIMESTAMP) /usr/lib/perl/5.6.1/CORE/perl.h $(INST_ARCHAUTODIR)/.exists -@$(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) config :: $(INST_MAN3DIR)/.exists @$(NOOP) $(INST_MAN3DIR)/.exists :: /usr/lib/perl/5.6.1/CORE/perl.h @$(MKPATH) $(INST_MAN3DIR) @$(EQUALIZE_TIMESTAMP) /usr/lib/perl/5.6.1/CORE/perl.h $(INST_MAN3DIR)/.exists -@$(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) help: perldoc ExtUtils::MakeMaker Version_check: @$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ -MExtUtils::MakeMaker=Version_check \ -e "Version_check('$(MM_VERSION)')" # --- MakeMaker linkext section: linkext :: $(LINKTYPE) @$(NOOP) # --- MakeMaker dlsyms section: # --- MakeMaker dynamic section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make dynamic" #dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM) dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) @$(NOOP) # --- MakeMaker dynamic_bs section: BOOTSTRAP = # --- MakeMaker dynamic_lib section: # --- MakeMaker static section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" #static :: Makefile $(INST_STATIC) $(INST_PM) static :: Makefile $(INST_STATIC) @$(NOOP) # --- MakeMaker static_lib section: # --- MakeMaker htmlifypods section: htmlifypods : pure_all @$(NOOP) # --- MakeMaker manifypods section: POD2MAN_EXE = /usr/bin/pod2man POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \ -e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "Makefile";' \ -e 'print "Manifying $$m{$$_}\n";' \ -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\047t install $$m{$$_}\n";' \ -e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}' manifypods : pure_all Fortune.pm @$(POD2MAN) \ Fortune.pm \ $(INST_MAN3DIR)/Fortune.$(MAN3EXT) # --- MakeMaker processPL section: # --- MakeMaker installbin section: # --- MakeMaker subdirs section: # none # --- MakeMaker clean section: # Delete temporary files but do not touch installed files. We don't delete # the Makefile here so a later make realclean still has a makefile to use. clean :: -rm -rf ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c mon.out core core.*perl.*.? *perl.core so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp -mv Makefile Makefile.old $(DEV_NULL) # --- MakeMaker realclean section: # Delete temporary files (via clean) and also delete installed files realclean purge :: clean rm -rf $(INST_AUTODIR) $(INST_ARCHAUTODIR) rm -f $(INST_LIBDIR)/Fortune.pm rm -rf Makefile Makefile.old # --- MakeMaker dist_basics section: distclean :: realclean distcheck distcheck : $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=fullcheck \ -e fullcheck skipcheck : $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=skipcheck \ -e skipcheck manifest : $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=mkmanifest \ -e mkmanifest veryclean : realclean $(RM_F) *~ *.orig */*~ */*.orig # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) @$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \ -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "Makefile";' tardist : $(DISTVNAME).tar$(SUFFIX) zipdist : $(DISTVNAME).zip $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(POSTOP) $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(POSTOP) uutardist : $(DISTVNAME).tar$(SUFFIX) uuencode $(DISTVNAME).tar$(SUFFIX) \ $(DISTVNAME).tar$(SUFFIX) > \ $(DISTVNAME).tar$(SUFFIX)_uu shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar $(RM_RF) $(DISTVNAME) $(POSTOP) # --- MakeMaker dist_dir section: distdir : $(RM_RF) $(DISTVNAME) $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" # --- MakeMaker dist_test section: disttest : distdir cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL cd $(DISTVNAME) && $(MAKE) cd $(DISTVNAME) && $(MAKE) test # --- MakeMaker dist_ci section: ci : $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \ -e "@all = keys %{ maniread() };" \ -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \ -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");' # --- MakeMaker install section: install :: all pure_install doc_install install_perl :: all pure_perl_install doc_perl_install install_site :: all pure_site_install doc_site_install install_vendor :: all pure_vendor_install doc_vendor_install install_ :: install_site @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_install :: pure_$(INSTALLDIRS)_install doc_install :: doc_$(INSTALLDIRS)_install pure__install : pure_site_install @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_perl_install :: @umask 022; $(MOD_INSTALL) \ read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ write $(INSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(INSTALLPRIVLIB) \ $(INST_ARCHLIB) $(INSTALLARCHLIB) \ $(INST_BIN) $(INSTALLBIN) \ $(INST_SCRIPT) $(INSTALLSCRIPT) \ $(INST_HTMLLIBDIR) $(INSTALLHTMLPRIVLIBDIR) \ $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \ $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ $(INST_MAN3DIR) $(INSTALLMAN3DIR) @$(WARN_IF_OLD_PACKLIST) \ $(SITEARCHEXP)/auto/$(FULLEXT) pure_site_install :: @umask 02; $(MOD_INSTALL) \ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(INSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(INSTALLSITELIB) \ $(INST_ARCHLIB) $(INSTALLSITEARCH) \ $(INST_BIN) $(INSTALLSITEBIN) \ $(INST_SCRIPT) $(INSTALLSITEBIN) \ $(INST_MAN1DIR) $(INSTALLSITEMAN1DIR) \ $(INST_MAN3DIR) $(INSTALLSITEMAN3DIR) @$(WARN_IF_OLD_PACKLIST) \ $(PERL_ARCHLIB)/auto/$(FULLEXT) pure_vendor_install :: @umask 022; $(MOD_INSTALL) \ $(INST_LIB) $(INSTALLVENDORLIB) \ $(INST_ARCHLIB) $(INSTALLVENDORARCH) \ $(INST_BIN) $(INSTALLBIN) \ $(INST_SCRIPT) $(INSTALLSCRIPT) \ $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ $(INST_MAN3DIR) $(INSTALLMAN3DIR) doc_perl_install :: @echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod -@umask 022; $(MKPATH) $(INSTALLARCHLIB) -@umask 022; $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLPRIVLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(INSTALLARCHLIB)/perllocal.pod doc_site_install :: @echo Appending installation info to $(INSTALLSITEARCH)/perllocal.pod -@umask 02; $(MKPATH) $(INSTALLSITEARCH) -@umask 02; $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(INSTALLSITEARCH)/perllocal.pod doc_vendor_install :: uninstall :: uninstall_from_$(INSTALLDIRS)dirs uninstall_from_perldirs :: @$(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist uninstall_from_sitedirs :: @$(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist # --- MakeMaker force section: # Phony target to force checking subdirectories. FORCE: @$(NOOP) # --- MakeMaker perldepend section: # --- MakeMaker makefile section: # We take a very conservative approach here, but it\'s worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. Makefile : Makefile.PL $(CONFIGDEP) @echo "Makefile out-of-date with respect to $?" @echo "Cleaning current config before rebuilding Makefile..." -@$(RM_F) Makefile.old -@$(MV) Makefile Makefile.old -$(MAKE) -f Makefile.old clean $(DEV_NULL) || $(NOOP) $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL "INSTALLDIRS=perl" @echo "==> Your Makefile has been rebuilt. <==" @echo "==> Please rerun the make command. <==" false # To change behavior to :: would be nice, but would break Tk b9.02 # so you find such a warning below the dist target. #Makefile :: $(VERSION_FROM) # @echo "Warning: Makefile possibly out of date with $(VERSION_FROM)" # --- MakeMaker staticmake section: # --- MakeMaker makeaperl section --- MAP_TARGET = perl FULLPERL = /usr/bin/perl $(MAP_TARGET) :: static $(MAKE_APERL_FILE) $(MAKE) -f $(MAKE_APERL_FILE) $@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) @echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) @$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ Makefile.PL DIR= \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= \ INSTALLDIRS=perl # --- MakeMaker test section: TEST_VERBOSE=0 TEST_TYPE=test_$(LINKTYPE) TEST_FILE = test.pl TEST_FILES = t/*.t TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) test :: $(TEST_TYPE) test_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' $(TEST_FILES) testdb_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERL) $(TESTDB_SW) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(TEST_FILE) test_ : test_dynamic test_static :: test_dynamic testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd: @$(PERL) -e "print qq{\n}. qq{\tFortune\n}. qq{\t\n}. qq{\t\n}. qq{\t\n}. qq{\t\t\n}. qq{\t\t\n}. qq{\t\t\n}. qq{\t\n}. qq{\n}" > Fortune.ppd # --- MakeMaker pm_to_blib section: pm_to_blib: $(TO_INST_PM) @$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \ "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \ -e "pm_to_blib({qw{$(PM_TO_BLIB)}},'$(INST_LIB)/auto','$(PM_FILTER)')" @$(TOUCH) $@ # --- MakeMaker selfdocument section: # --- MakeMaker postamble section: # End. libfortune-perl-0.2/pm_to_blib0100644000175000017500000000000007315763025016510 0ustar stratusstratuslibfortune-perl-0.2/build-stamp0100644000175000017500000000000007315763025016623 0ustar stratusstratus