#!/usr/bin/perl

use strict;
use warnings;

my $content = qq{
module whatever
//endmodule
// endmodule
// asadsadadsa endmodule
// enasaa endmodule asas
/* endmodule */
/* blabl
endmodule // whatever
blabla */
// endmodule // whatever
endmodule // whatever
module nonsense
//
// bla bla
//
endmodule // nonsense
};

if ($content =~ m~
  module\s+whatever      # marks the start of the module
  (?:                    # each instance of this alternation matches one kind of
                         # module "token"
    //.*+                # match a single-line comment
  |                      # or
    /[*]                 # open a block comment
    (?:(?![*]/)[\s\S])*+ # match anything as long as it doesn't close the comment
    [*]/                 # close the block comment
  |                      # or
    (?!endmodule)[\s\S]  # match anything as long as it doesn't close the module
  )*+                    # repeat
  endmodule
  ~x) {
    print $&;
}
else
{
    print "NOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!!!!\n";
}