in reply to Converting C #define to 'use constant' statements

Useless use of cat, as merlyn would (will?:) say.

Try this:

perl -ne 'print if s!#\s*define\s+(\S+)\s+([^(?:\s*/\*.*\*/)])$!use co +nstant $1 => $2;!g' /usr/include/linux/elf.h >> Constants.pm

Replies are listed 'Best First'.
(tye)RE: Converting C #define to 'use constant' statements
by tye (Sage) on Nov 03, 2000 at 20:35 UTC

    No need to rewrite the script to kill one cat:

    perl def2const.pl /usr/include/linux/elf.h >>Constants.pm

            - tye (but my friends call me "Tye")
      Yes, but part of my point--no, I didn't mention it :)--was that the original script was reading the entire input into memory. The slight rewrite I did doesn't do that. And I realize that, w/ an include file, it's probably not that much of an issue; but I don't like the idea of reading an entire file into memory when it could be done more easily as a filter.