Reputation: 89
i have a file from which i have to grep multiple lines between two specific string and save it to a new file as it is ..
The file is as below:
module abc (
abc,
efg,
..
..
);
core M1 sj
corem m2
apple
......
the starting string is module and last string is ");" . The desired output is as below:
module abc (
abc,
efg,
..
..
);
below is the script which i had tried :
open(my $fh, "<", "test.v")
or die "Failed to open file: $!\n";
my $original = <$fh>;
close($fh);
open(INFILE, ">", "result.v")
my $abc = $original =~ /module .*\)\;/ ; //selecting string from module to ");"
print INFILE $abc;
close(INFILE);
Kindly help me with a perl script .
Thank You
Upvotes: 0
Views: 81
Reputation: 386396
perl -ne'print if /^module/ .. /^\s*\);/'
Specifying file to process to Perl one-liner
Upvotes: 2