OVH Cloud OVH Cloud

reverse : bug ?

5 réponses
Avatar
Pierre-Yves
Bonjour,

Je me demande si il n'y a pas un bug dans la fonction "reverse"; en effet
j'ai un array qui contient ceci :
(j'utilise perl 5.8.2 on Solaris 5.8)

/default/main/prd/intranet/thematics/th_b2e
/default/main/prd/intranet/thematics/th_b2e/tp01_topicCV1
/default/main/prd/intranet/thematics/th_b2e/th01_testCV
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0101_testCV2
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0102_testCV3
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0103_testCV4
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0104_testCV5
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0105_testCV6
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0106_testCV7
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0107_testCV8
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0108_testCV9
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0109_testCV10
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0110_testCVNew
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0111_testCVBis
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0112_testCVForLog
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0113_testCV1905
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0114_testCV2005
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3205
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3305
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3405
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3505
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/testInterW
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3605
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0116_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0117_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th02_testCV
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0201_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2/tp02020101_ConversionTopic3


et quand je fais "reverse @myArray" j'obtiens ceci.

/default/main/prd/intranet/thematics/th_b2e
/default/main/prd/intranet/thematics/th_b2e/th02_testCV
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2/tp02020101_ConversionTopic3
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0201_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0117_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0116_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3605
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/testInterW
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3505
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3405
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3305
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3205
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0114_testCV2005
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0113_testCV1905
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0112_testCVForLog
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0111_testCVBis
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0110_testCVNew
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0109_testCV10
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0108_testCV9
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0107_testCV8
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0106_testCV7
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0105_testCV6
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0104_testCV5
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0103_testCV4
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0102_testCV3
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0101_testCV2
/default/main/prd/intranet/thematics/th_b2e/tp01_topicCV1


D'après le cookbook de o'reilly "reverse" et une "boucle inversée" devrait
donner la même chose :

# reverse @ARRAY into @REVERSED
@REVERSED = reverse @ARRAY;Or use a for loop:

for ($i = $#ARRAY; $i >= 0; $i--) {
# do something with $ARRAY[$i]
}

Regards,
P-Yves.

5 réponses

Avatar
JacK
Le 20/06/2005 13:12, :
Bonjour,

Je me demande si il n'y a pas un bug dans la fonction "reverse";


Je n'ai pas de souci avec reverse.

Vérifier votre tableau en entrée.

Avatar
Pierre-Yves
c'est fait

*** Ceci
/default/main/prd/intranet/thematics/th_b2e
/default/main/prd/intranet/thematics/th_b2e/tp01_topicCV1
/default/main/prd/intranet/thematics/th_b2e/th01_testCV
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0101_testCV2
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0102_testCV3
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0103_testCV4
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0104_testCV5
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0105_testCV6
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0106_testCV7
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0107_testCV8
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0108_testCV9
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0109_testCV10
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0110_testCVNew
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0111_testCVBis
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0112_testCVForLog
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0113_testCV1905
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0114_testCV2005
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3205
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3305
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3405
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3505
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/testInterW
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3605
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0116_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0117_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th02_testCV
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0201_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2/tp02020101_ConversionTopic3

*** Devient ceci (reverse)
/default/main/prd/intranet/thematics/th_b2e
/default/main/prd/intranet/thematics/th_b2e/th02_testCV
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2/tp02020101_ConversionTopic3
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0201_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0117_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0116_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3605
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/testInterW
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3505
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3405
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3305
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3205
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0114_testCV2005
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0113_testCV1905
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0112_testCVForLog
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0111_testCVBis
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0110_testCVNew
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0109_testCV10
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0108_testCV9
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0107_testCV8
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0106_testCV7
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0105_testCV6
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0104_testCV5
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0103_testCV4
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0102_testCV3
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0101_testCV2
/default/main/prd/intranet/thematics/th_b2e/tp01_topicCV1

Comme vous pouvez le voir le second n'est pas le premier inversé !!!



"JacK" wrote in message
news:d96fc1$
Le 20/06/2005 13:12, :
Bonjour,

Je me demande si il n'y a pas un bug dans la fonction "reverse";


Je n'ai pas de souci avec reverse.

Vérifier votre tableau en entrée.



Avatar
Patrick Mevzek

c'est fait


Donnez le code source de votre programme !
et notamment le bout qui affiche ce que vous copiez collez ici.

--
Patrick Mevzek . . . . . . Dot and Co (Paris, France)
<http://www.dotandco.net/> <http://www.dotandco.com/>
Dépêches sur le nommage <news://news.dotandco.net/dotandco.info.news>

Avatar
Yann Coscoy
et quand je fais "reverse @myArray" j'obtiens ceci.


La fonction reverse ne fait pas de modification en place.
Si c'est ce que l'on veut, il ne faut pas faire

reverse @myArray;

may

@myArray = reverse @myArray;


Yann Coscoy

Avatar
JacK
Le 20/06/2005 15:39, :
c'est fait

*** Ceci
/default/main/prd/intranet/thematics/th_b2e
/default/main/prd/intranet/thematics/th_b2e/tp01_topicCV1
/default/main/prd/intranet/thematics/th_b2e/th01_testCV
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0101_testCV2
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0102_testCV3
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0103_testCV4
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0104_testCV5
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0105_testCV6
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0106_testCV7
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0107_testCV8
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0108_testCV9
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0109_testCV10
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0110_testCVNew
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0111_testCVBis
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0112_testCVForLog
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0113_testCV1905
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0114_testCV2005
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3205
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3305
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3405
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3505
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/testInterW
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3605
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0116_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0117_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th02_testCV
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0201_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2/tp02020101_ConversionTopic3

*** Devient ceci (reverse)
/default/main/prd/intranet/thematics/th_b2e
/default/main/prd/intranet/thematics/th_b2e/th02_testCV
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTop
ic1/tp020201_ConversionTopic2/tp02020101_ConversionTopic3
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0201_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0117_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0116_testCV0206
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3605
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/testInterW
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3505
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3405
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3305
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0115_testCV3205
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0114_testCV2005
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0113_testCV1905
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0112_testCVForLog
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0111_testCVBis
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0110_testCVNew
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0109_testCV10
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0108_testCV9
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0107_testCV8
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0106_testCV7
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0105_testCV6
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0104_testCV5
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0103_testCV4
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0102_testCV3
/default/main/prd/intranet/thematics/th_b2e/th01_testCV/tp0101_testCV2
/default/main/prd/intranet/thematics/th_b2e/tp01_topicCV1

Comme vous pouvez le voir le second n'est pas le premier inversé !!!



/default/main/prd/intranet/thematics/th_b2e
/default/main/prd/intranet/thematics/th_b2e/tp01_topicCV1
/default/main/prd/intranet/thematics/th_b2e/th01_testCV
....

et via reverse
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTopic1/tp020201_ConversionTopic2/tp02020101_ConversionTopic3
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTopic1/tp020201_ConversionTopic2
/default/main/prd/intranet/thematics/th_b2e/th02_testCV/tp0202_ConversionTopic1
...








"JacK" wrote in message
news:d96fc1$
Le 20/06/2005 13:12, :
Bonjour,

Je me demande si il n'y a pas un bug dans la fonction "reverse";
Je n'ai pas de souci avec reverse.


Vérifier votre tableau en entrée.