Permalink
Browse files

Got P<> and M<> tags working how I wanted

  • Loading branch information...
1 parent 3687aef commit 1e1d18c57108ef1bc5586eb357fa8a65088f56ae @petdance committed May 4, 2007
Showing with 25 additions and 23 deletions.
  1. +10 −8 crank
  2. +15 −15 s/flow-control.pod
View
18 crank
@@ -91,6 +91,10 @@ sub pod2html {
$parser->output_string( \$html );
$parser->parse_file( $podfile );
+ # Manually adjust the stuff we passed thru earlier
+ $html =~ s{P<(.+?)>}{<a href="http://perldoc.perl.org/$1.html">$1</a>}g;
+ $html =~ s{M<(.+?)>}{<a href="http://search.cpan.org/perldoc?$1">$1</a>}g;
+
return $html;
}
@@ -106,17 +110,15 @@ sub VERSION { '0.01' };
sub new {
my $self = shift->SUPER::new(@_);
- $self->accept_codes( qw( P M ) );
+ my @passthru = qw( P M ); # P = Perldoc, M = Module
+ $self->accept_codes( @passthru );
my $tagmap = $self->{Tagmap};
- # Perldoc links
- $tagmap->{P} = qq{<a href="http://perldoc.perl.org/};
- $tagmap->{'/P'} = qq{.html">this page</a>};
-
- # Module links
- $tagmap->{M} = qq{<a href="http://search.cpan.org/perldoc?};
- $tagmap->{'/M'} = qq{">here</a>};
+ for my $code ( @passthru ) {
+ $tagmap->{$code} = "$code<";
+ $tagmap->{"/$code"} = ">";
+ }
return $self;
}
View
@@ -1,5 +1,17 @@
=head1 Flow control
+=head2 Four values of false
+
+There are four ways to have a false value in Perl:
+
+ my $false = undef;
+ $false = "";
+ $false = 0;
+ $false = "0";
+
+The last one is false because "0" becomes 0 in numeric
+context, which is false by the third rule.
+
=head2 postfix controls
A simple C<if> or C<unless> block might look like this:
@@ -18,7 +30,7 @@ This also works for C<while> and C<for>.
print $i++ . "\n" while $i < 10;
-=head2 For loops (for and foreach are really synonyms)
+=head2 C<for> loops
There are three styles of for loops.
@@ -41,7 +53,7 @@ You may see C<foreach> used in place of C<for>. The two
are interchangable. Most people use C<foreach> for the
last two styles of loops above.
-=head2 do
+=head2 C<do> blocks
C<do> allows Perl to use a block where a statement is expected.
@@ -63,7 +75,7 @@ As a special case, C<while> runs the block at least once.
do { action(); } while action_needed;
-=head2 if/elsif/else BUT NO case
+=head2 Perl has no C<switch> or C<case>
If you're coming from another language, you might be used
to C<case> statements. Perl doesn't have them.
@@ -83,18 +95,6 @@ The closest we have is C<elsif>:
There is no way to fall through cases cleanly.
-=head2 Four values of false
-
-There are four ways to have a false value in Perl:
-
- my $false = undef;
- $false = "";
- $false = 0;
- $false = "0";
-
-The last one is false because "0" becomes 0 in numeric
-context, which is false by the third rule.
-
=head2 next/last/continue/redo
Consider the following loop:

0 comments on commit 1e1d18c

Please sign in to comment.