| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::Be::Modern; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 48805 | use Modern::Perl; | 
|  | 2 |  |  |  |  | 28970 |  | 
|  | 2 |  |  |  |  | 58 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 2 |  |  | 2 |  | 2337 | use Filter::Util::Call; | 
|  | 2 |  |  |  |  | 2010 |  | 
|  | 2 |  |  |  |  | 436 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =encoding utf-8 | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 NAME | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | Acme::Be::Modern - enables your script to "be modern" | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 VERSION | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | Version 0.03 | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | =cut | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | our $VERSION = '0.03'; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | This is a thin (and stupid) wrapper (actually a source filter) around | 
| 25 |  |  |  |  |  |  | L. It makes it possible to write 'be modern' instead of | 
| 26 |  |  |  |  |  |  | 'use Modern::Perl' - like this: | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | use Acme::Be::Modern; | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | be modern; # all lowercase is actually postmodern :-/ | 
| 31 |  |  |  |  |  |  | ... | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =cut | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head1 WARNING | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | The source filter (defined in the L sub is | 
| 38 |  |  |  |  |  |  | simply a naive search-and-replace. Don't use this in any real code. | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | =head1 IMPLEMENTATION | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | The implementation is a slight variation of the example in | 
| 43 |  |  |  |  |  |  | L. It's implemented using two functions: | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =head2 import | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | This will be called after L has been loaded. Simply | 
| 48 |  |  |  |  |  |  | calls filter_add() with a blessed reference. Now the filter is | 
| 49 |  |  |  |  |  |  | activated. | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =cut | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub import { | 
| 54 | 2 |  |  | 2 |  | 19 | my ($type) = @_; | 
| 55 | 2 |  |  |  |  | 4 | my ($ref) = []; | 
| 56 | 2 |  |  |  |  | 8 | filter_add(bless $ref); | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =head2 filter | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | The actual filter. Will receive source lines by calling | 
| 63 |  |  |  |  |  |  | filter_read(). Any occurrence (and I mean any) of 'be modern' will be | 
| 64 |  |  |  |  |  |  | replace with 'use Modern::Perl'. | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =cut | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | sub filter { | 
| 69 | 9 |  |  | 9 | 1 | 3579 | my ($self) = @_; | 
| 70 | 9 |  |  |  |  | 11 | my ($status); | 
| 71 | 9 | 100 |  |  |  | 49 | s/be modern/use Modern::Perl/g if ($status = filter_read()) > 0; | 
| 72 | 9 |  |  |  |  | 2971 | $status; | 
| 73 |  |  |  |  |  |  | } | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | =head1 AUTHOR | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | Søren Lund, C<<  >> | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head1 BUGS | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | Yes! This is buggy. It's a source filter, and it's really stupid. Any | 
| 82 |  |  |  |  |  |  | text in your source matching 'be modern' will be replaced with 'use | 
| 83 |  |  |  |  |  |  | Modern::Perl'. | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | Please report any bugs or feature requests to C, or through | 
| 86 |  |  |  |  |  |  | the web interface at L.  I will be notified, and then you'll | 
| 87 |  |  |  |  |  |  | automatically be notified of progress on your bug as I make changes. | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head1 SUPPORT | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | perldoc Acme::Be::Modern | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | You can also look for information at: | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =over 4 | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | =item * RT: CPAN's request tracker | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | L | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | L | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | L | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =item * Search CPAN | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | L | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =back | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | Copyright 2011 Søren Lund. | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | This program is free software: you can redistribute it and/or modify | 
| 123 |  |  |  |  |  |  | it under the terms of the GNU General Public License as published by | 
| 124 |  |  |  |  |  |  | the Free Software Foundation, either version 3 of the License, or | 
| 125 |  |  |  |  |  |  | (at your option) any later version. | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | This program is distributed in the hope that it will be useful, | 
| 128 |  |  |  |  |  |  | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 129 |  |  |  |  |  |  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 130 |  |  |  |  |  |  | GNU General Public License for more details. | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | You should have received a copy of the GNU General Public License | 
| 133 |  |  |  |  |  |  | along with this program.  If not, see . | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | =cut | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | 1; # End of Acme::Be::Modern |