#!/usr/bin/perl use strict; use warnings; undef $/; my $code = ; # $code =~ s|^\s*/\*.*?\*/||gm; # Changed as per anjiro's comments $code =~ s#^\s*/\*.*?\*/##gm; $code =~ s#(?<=\S)\s/\*.*?\*/\s*?$##gm; $code =~ s#\n##ms; print $code; __DATA__ /*This is a bogus function*/ void function foo(void) /*My function is the best*/ { int i; /*i is an integer*/ int j; /*j is also an integer*/ /*Now I'm going to set i to 1*/ i = 1; /*Also j*/ j = 1; /*Here's some incrementing!*/ i++; /*And more!*/ j++; /*The end!*/}