Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Embedding pod in C

by jpl (Monk)
on May 18, 2011 at 17:25 UTC ( #905522=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Embedding pod in C
in thread Embedding pod in C

A followup to my own followup (but not as a reply, which could drive the depth of the replies below the default level of visibility).

The preprocessor could take, as arguments, two patterns to identify the start and the end of the pod block. This would make it more general than something dependent on C conventions.

Update: and maybe another pattern to determine what should be deleted from the start of each line in the pod block, so we don't have to rely on white space.

Update #2: First approximation (missing way to set patterns):

#!/usr/bin/perl -w use strict; my $start = qr{^.*#\s*ifdef\s+pod}; my $stop = qr{^.*#\s*endif\s*/\*\s*pod\s*\*/}; my $trim = qr{^\s*}; my $verb = qr{^\s*=v\s}; my $show = 0; while ( my $line = <DATA> ) { if ( $line =~ $start ) { $show = 1; next; } if ( $line =~ $stop ) { $show = 0; next; } if ($show) { chomp($line); $line =~ s/$trim//; $line =~ s/$verb//; print $line, "\n"; } } __DATA__ This could be anything #ifdef pod =head2 title blah, blah,blah =v indent 1 #endif /* pod */ This could be anything, too


Comment on Re^4: Embedding pod in C
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://905522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-12-20 13:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls