Removing comments using Perl

Posted by justintime on Stack Overflow See other posts from Stack Overflow or by justintime
Published on 2010-04-10T18:30:18Z Indexed on 2010/04/10 18:33 UTC
Read the original article Hit count: 358

Filed under:

Something I keep doing is removing comments from a file as I process it. I was was wondering if there a module to do this.

Sort of code I keep writing time and again is

    while(<>) {
        s/#.*// ;
        next if /^ \s+ $/x ;

        **** do something useful here ****
    }

© Stack Overflow or respective owner

Related posts about perl