Aide sur fonction Grep sur un tableau contenant des regex
Bonjour,
J'ai un problème pour retourner une liste d'url d'un tableau.
J'ai donc un tableau comme ceci :
Code:
1 2 3 4 5
| http://www.toto.fr/dossier[1|2]/index.html
http://www.titi.fr/dossier/index.html
http://www.toto.fr/dossier1/index.html
http://www.toto.fr/dossier2/index.html
http://www.titi.fr/ |
Quand je fait un grep sur "http://www.toto.fr/dossier1/index.html"
J'aimerai que le grep me retourne : http://www.toto.fr/dossier[1|2]/index.html et http://www.toto.fr/dossier1/index.htm
Avec mon code il ne me retourne que http://www.toto.fr/dossier1/index.html
Voilà mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11
| #!/usr/bin/perl
use strict;
use Data::Dumper;
my @url = qw("http://www.toto.fr/dossier[1|2]/index.html" "http://www.titi.fr/dossier/index.html" "http://www.toto.fr/dossier3/index.html" "http://www.toto.fr/dossier4/index.html" "http://www.titi.fr/");
my $addr = "http://www.toto.fr/dossier1/";
my @result = grep { /$addr/ } @url;
print Dumper @result; |
Merci d'avance pour votre aide
Franpom