in reply to C code pre-processor

Try Text::CPP. It's light, fast, and easy to use.
#!/usr/bin/perl use strict; use warnings; use Text::CPP; my $MyData = <DATA>; my $reader = new Text::CPP( Language => 'STDC99', Options => {}, Builtins => { foo => 'this', bar => 'that', }, ); $reader->read('/root/Desktop/file.c'); while (my $token = $reader->token) { print "Token: $token\n"; } $reader->data->{MyKey} = $MyData; __DATA__ #ifdef pathtest 38. This should appear. #else #define pathtest 37. This should appear. #include test.txt 39. This should appear. #undef pathtest #endif

Replies are listed 'Best First'.
Re^2: C code pre-processor
by educated_foo (Vicar) on Feb 03, 2012 at 19:52 UTC
    It's also XS, so he'll need a C preprocessor to install it in the first place.
      Hi, I was away for the last few days so I just saw your post. What is XS?
        It's Perl's way of interacting with C libraries; see perlxs. Installing an XS module requires a C compiler.