in reply to RegEx - comments should not matches
#!/usr/bin/perl use strict; use warnings; if(!@ARGV) { die "program file.c\n"; } open(FILE,"<$ARGV[0]")|| die "Impossible to open $ARGV[0]\n"; my $ig=0; while(<FILE>) { if($_ =~ /\*\//) { $ig=0; next; } next if(($_ =~ /(^\s+|^\t+|^)\/\//)||($_ =~ /(^\s+|^\t+|^)\/\* +.+\*\//)); $ig=1 if($_ =~ /\/\*/); next if($ig == 1); print "$_"; } exit;
|
|---|