Récupération de ligne à partir d'un index

Résolu/Fermé
remousse Messages postés 299 Date d'inscription dimanche 2 novembre 2008 Statut Membre Dernière intervention 20 novembre 2014 - 28 févr. 2013 à 10:42
remousse Messages postés 299 Date d'inscription dimanche 2 novembre 2008 Statut Membre Dernière intervention 20 novembre 2014 - 28 févr. 2013 à 11:19
Bonjour,

Je scanne un document word par paragraphe et j'aimerai récupérer toutes les lignes situé après un paragraphe en question.
Pour être plus clair, dans mon code ci-dessous, je veux récupérer tout ce qu'il y a après la ligne commençant par REGLE.

for my $p (1..$n_paragraphs) {
		my $regle = "REGLE";
		my $paragraph = $paragraphs->Item ($p);
		my $text = $paragraph->{Range}->{Text};
		my $start_index;
		if ($text =~/^$regle/){
			$start_index = $p;
		}
		if (defined($start_index)){
			print "P = $p\n";
			print "I = $start_index\n";
			if ($p > $start_index){
				print RULE "$text\n";
			}
		}
	}


Cependant je ne récupère rien du tout et cela est normal car ma variable
$start_index
n'est définie qu'une seule fois, au moment où je me trouve sur la ligne commençant par REGLE.

Comment faire pour récupérer les lignes situées après celle-ci ?

Par avance merci.

A voir également:

1 réponse

remousse Messages postés 299 Date d'inscription dimanche 2 novembre 2008 Statut Membre Dernière intervention 20 novembre 2014 6
28 févr. 2013 à 11:19
Problème résolu :

for my $p (1..$n_paragraphs) {
		my $regle = "REGLE";
		my $paragraph = $paragraphs->Item ($p);
		my $text = $paragraph->{Range}->{Text};
		my $start_index;
		if ($text =~/^$regle/){
			$start_index = $p;
		}
		if (defined($start_index)){
			for my $r ($start_index+1..$n_paragraphs) {
				$paragraph = $paragraphs->Item ($r);
				$text = $paragraph->{Range}->{Text};
				$text =~ s/[\n]//g;
				print RULE "$text";
			}
			
		}
	}
0