use warnings; open(CITY, "city.cpp.txt") || die("sorry, file couldn't be opened. $!"); while ($content=) { if ($content!~m#//|/\*#) { print "$content"; } elsif ($content=~m#/\*#) { while (!~m#\*/#) { } } }