Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2016-02-14 08:59 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (467 votes), past polls