in reply to find a string into an interval

Assuming your file is large and has to be read line by line, and assuming there may be more than one line with a match:
#!/usr/bin/perl -w $s1 = 'exp1'; $s2 = 'exp2'; open(FICH, "a.txt"); while (<FICH>) { if ($_ =~ /$s1(.*?)$s2/) { print "$1\n"; } } close FICH;