#!/usr/bin/perl -w $s1 = 'exp1'; $s2 = 'exp2'; open(FICH, "a.txt"); while () { if ($_ =~ /$s1(.*?)$s2/) { print "$1\n"; } } close FICH;