Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://905522]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-03-19 01:53 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.