Greetings all,
If your file is small you could always read it in as a string and then ignore the newlines "\n" by using the s modifier.
Here is my example sans relevant error checking... I made a plain text file with your original posted data for testing (That is what the your_file is referring to)
#!/usr/bin/perl -w
use strict;
unless (open(F,'./your_file')){
die "Unable to open file for reading $!";
}else{
my $file_str = join("",<F>);
close F;
if($file_str =~ m/^(\.subckt.*?)x00/s){
my $match_str = $1;
print $match_str."\n";
}else{
print "No match for you!";
}
exit;
}
__OUTPUT__
.subckt cct0 v0 v1 v2 v3
+ v4 v5 v6
* useless comment
+ v7 v8 v9
+ va vb
A little explaination.
The 'm/^(\.subckt.*?)x00/s' is matching as if the string were a single line so \n's are ignored (or included with '.' however you look at it you can match across newlines with the 's' modifier), the '.*?' is doing a non-greedy match, without the '?' the '.*' would match as much as possible, this really only matters when you have the same pattern present in your search and you want to limit which one the regexp stops at.
hope that helps.
-injunjoel