in reply to regexp match up to but not incliuding...

A positive zero-width lookahead isn't going to be helpful if your current idiom of reading one line at a time and matching using a flopflop operator.

Here's one possible solution:

use strict; use warnings; while ( $_ = <DATA> and /^\.subckt/../^\w/ ) { last if /^\w/; print; } __DATA__ .subckt cct0 v0 v1 v2 v3 + v4 v5 v6 * useless comment + v7 v8 v9 + va vb x00 v0 v1 x0 cct1 .ends

This has the disadvantage of performing a couple of pattern matches on every line of the file read. However, it improves upon your snippet by jumping out of the loop the instant it detects the end of the data you're looking for.


Dave