http://qs1969.pair.com?node_id=480275


in reply to \G assertion

I need to print from one string to another using .. with \G My goal is to capture from allsets down.

Capture into what? A string? An array? If you just want to capture everything from /allsets/ .. /fs_clinical\.1/ into a scalar string then you can just do something like:

my $captured = ""; while ( <ARC> ) { $captured .= $_ if ( /allsets/ .. /fs_clinical\.1/ ); }

...but you seem to be trying to do something more. I don't know what you are trying to do with the / \G 'heartlab.1'/, but that isn't doing anything at all currently. \G generally doesn't make any sense unless it is used with /g and in some sort of a looped match. You don't have a looped match here, since you are changing the match-subject on each iteration.

Additionally, $1 is populated by (successful) capturing matches. You don't have any of those, so $1 is empty, if you are lucky. Mind you, you are assigning to a variable in a uselessly small scope, so it doesn't matter anyway.