http://qs321.pair.com?node_id=670607


in reply to get the rest of the text

Here are some thought about your code.

Something along these lines (not tested).

use strict; use warnings; my $element = q{coucou}; my $inFile = q{EXEMPLE.txt}; my $outFile = qq{RESEARCHED_text_${element}.txt}; open my $inFH, q{<}, $inFile or die qq{open: $inFile: $!\n}; open my $outFH, q{>}, $ourFile or die qq{open: $outFile: $!\n}; while ( <$inFH> ) { next unless m{(.*?)$element(.*); print $outFH; my $beforeElement = $1; my $afterElement = $2; # Do something here with your captured text ... } close $inFH or die qq{close: $inFile: $!\n}; close $outFH or die qq{close: $outFile: $!\n};

I hope this is of use.

Cheers,

JohnGG