#!/usr/bin/perl;

# Programme de recherche d'un motif :

open(FILE1,"$ARGV[0]"); # ouvre moi un fichier qui s'appelerait ARGV[0]
open(FILE2,">$ARGV[1]"); # ouvre moi un fichier en écriture qui s'appelerait ARGV[1]

$motif="[Pp]rintemps|[Ff]r[üu][^]*hling|[Ff]r[üu][^]*hjahr|[Ss]pring"; # donne moi le motif recherché en le nommant ARGV[2]

while ($ligne=<FILE1>) { # tant qu'il y a une ligne dans FILE1
	if ($ligne=~/$motif/i) { # si la ligne contient le motif recherché
		my $motifreconnu= $&;
		my $gauche = $`;
		my $droite = $';
		print FILE2 "$gauche\n $motifreconnu\n $droite\n"; # je l'écris dans FILE2
		} # sinon rien ne se passe
	}

close(FILE1);
close(FILE2);
exit;
