| 1 | package Bone::Easy; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | require Exporter; | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Bone::Easy::Rules; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use vars qw($VERSION %Rules @EXPORT @ISA $Rules_Fh $Start_Kind); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | $VERSION = '0.04'; | |||||||||
| 10 | 1 | @ISA = qw(Exporter); | |||||||||
| 11 | 1 | @EXPORT = qw(pickup); | |||||||||
| 12 | |||||||||||
| 13 | 1 | $Rules_Fh = *Bone::Easy::Rules::DATA; | |||||||||
| 14 | 1 | load_rules(); | |||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | sub load_rules { | ||||||||
|
Subroutine
load_rules: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 17 | 1 | ▶ | while(my $rule = <$Rules_Fh>) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 770 | ▶ | next unless $rule =~ /\S+/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | |||||||||||
| 20 | 673 | chomp $rule; | |||||||||
| 21 | 673 | $rule =~ s/\s+$//; | |||||||||
| 22 | |||||||||||
| 23 | 673 | my($kind, $text) = $rule =~ /^(.*)-->(.*)$/; | |||||||||
| 24 | 673 | push @{$Rules{$kind}}, $text; | |||||||||
| 25 | } | ||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 1 | $Start_Kind = 'REMARK'; | |||||||||
| 29 | 1 | ▶ | sub pickup { | ||||||||
|
Subroutine
pickup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 30 | 1 | my $line = ${$Rules{$Start_Kind}}[rand @{$Rules{$Start_Kind}}]; | |||||||||
| 31 | |||||||||||
| 32 | 1 | return ucfirst replace($line); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 4 | ▶ | sub replace { | ||||||||
|
Subroutine
replace: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 36 | 4 | my $line = shift; | |||||||||
| 37 | |||||||||||
| 38 | 4 | $line =~ s{(\b[A-Z]{2,}\b)} | |||||||||
| 39 | { | ||||||||||
| 40 | exists $Rules{$1} | ||||||||||
| 41 | 3 | ▶ | ? replace(${$Rules{$1}}[rand @{$Rules{$1}}]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | : $1 | ||||||||||
| 43 | }eg; | ||||||||||
| 44 | |||||||||||
| 45 | 4 | return $line; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | =pod | ||||||||||
| 50 | |||||||||||
| 51 | =head1 NAME | ||||||||||
| 52 | |||||||||||
| 53 | Bone::Easy - Perl module for generating pickup lines. | ||||||||||
| 54 | |||||||||||
| 55 | =head1 SYNOPSIS | ||||||||||
| 56 | |||||||||||
| 57 | use Bone::Easy; | ||||||||||
| 58 | |||||||||||
| 59 | # I know you get this a lot, but what's a unholy fairy like you | ||||||||||
| 60 | # doing in a mosque like this? | ||||||||||
| 61 | print pickup, "\n"; | ||||||||||
| 62 | |||||||||||
| 63 | =head1 DESCRIPTION | ||||||||||
| 64 | |||||||||||
| 65 | Generates pickup-lines GUARANTEED to get something thrown in your face. | ||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | =head1 AUTHOR | ||||||||||
| 69 | |||||||||||
| 70 | Idea and original ruleset by TheSpark.com <http://www.thespark.com> | ||||||||||
| 71 | and Chris Coyne <ccoyne@staff.thespark.com> | ||||||||||
| 72 | |||||||||||
| 73 | Perl Code by Michael G Schwern <schwern@pobox.com> | ||||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | =head1 LICENSE | ||||||||||
| 77 | |||||||||||
| 78 | This program may be distributed under the same license as Perl itself, | ||||||||||
| 79 | except for Bone::Easy::Rules. L<Bone::Easy::Rules> for details. | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | =head1 SEE ALSO | ||||||||||
| 83 | |||||||||||
| 84 | L<Safe>, L<Sex>, L<pickup>, L<Bone::Easy::Rules> | ||||||||||
| 85 | |||||||||||
| 86 | =cut | ||||||||||
| 87 | |||||||||||
| 88 | |||||||||||
| 89 | 1 | 1; | |||||||||