use strict ; use warnings ;
my $data ;
{ local $/ ; $data = <DATA> ; } ;
my $s = 'bc' ; # Substring to search for in left hand side
my @r = ($data =~ m/$s[^\s]*[ \t]+(.*)/g) ;
print "@r\n" ;
__DATA__
abcd s1
efgh s2
ijklm s3
nopq s4
bc s5
aqbc s6
rst s7
uvwx s8
yz s9
noting that the [ \t]+ can be changed to simply \t for use with your file (I've used [ \t]+ here only because that works even if the stuff between the "blocks" has been converted to any mixture tabs and spaces). Noting also that the (.*) will stop at end of line.
Note also that this is assuming that the right hand side will not contain any tabs (or spaces)
The regex can match to the search substring in the right hand side, but since that ends in a newline, the [^\s]*[ \t]+ part will fail the match.
The following: my $data = "\n" ;
{ local $/ ; $data .= <DATA> ; } ;
my $s = 'bc' ; # Substring to search for in left hand side
my @r = ($data =~ m/\n.*?$s[^\s]*[ \t]+(.*)/g) ;
avoids matching in the right hand side, and the right hand side can contain tabs (and spaces). I don't have enough data to know if there's any performance advantage or disadvantage here.
|