in reply to how to split file with some pattern

Hello, you asked the wrong question: if you split your file using "module xxx/endmodule" you end up with two empty lines.
What you really want is to grab everything between two markers to go in separates files. I underline this because the wrong question preclude you to obtain good answers.

In the case you describe you'll find very useful the flip-flop operator, a not well known operator, very useful insetad, described in the docs

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @files; my $file_index=0; while (<DATA>) { if ($_ =~ /^module\s+/ .. /endmodule$/){ $files[$file_index].=$_; } else {++$file_index;} } print scalar @files," elements in \@files:\n",Dumper (\@files); __DATA__ module soc (PAD_TEST , VDIG_ON , GNDD_ON , VPP_EF , PAD_BOND_OPT ); inout [31:0] PAD_TEST ; input VDIG_ON ; input GNDD_ON ; inout VPP_EF ; inout [5:0] PAD_BOND_OPT ; endmodule module analog_atop_wrapper (PAD_VDDTX , PAD_VREFADC , PAD_VSSRF , DPAD_GSUB_XTAL24M , DPAD_GSUB_RX ); inout PAD_VDDTX ; inout PAD_VREFADC ; inout PAD_VSSRF ; inout DPAD_GSUB_XTAL24M ; inout DPAD_GSUB_RX ; endmodule module misc_atop_wrapper (VDIG , VRTC , AVDD , EBUS , IOGND , VDIG_ON +); inout VDIG ; inout VRTC ; inout AVDD ; inout EBUS ; inout IOGND ; input VDIG_ON ; endmodule


HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.