IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Perl Discussion :

perldb n'est pas cohérent


Sujet :

Langage Perl

  1. #1
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    29
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations forums :
    Inscription : Janvier 2007
    Messages : 29
    Par défaut perldb n'est pas cohérent
    Bonjour à tous,

    Un print $_ ne remplissant pas son rôle dans un de mes scripts, j'ai cherché l'erreur avec perldb, et je tombe des nues :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
     DB<15> p "$Answer[$number]"
    blackie
      DB<16> p "$Answer[$number],$number"
    ,1
      DB<17> p "BOUZAAA,$number"
    BOUZAAA,1
      DB<18> p "$number,$number"
    1,1
      DB<19>
    Dites moi si je me trompes, mais en 16, il devrait répondre blackie,1, n'est-ce pas ?

  2. #2
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    on est pas des magiciens, montre nous ton code

  3. #3
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    29
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations forums :
    Inscription : Janvier 2007
    Messages : 29
    Par défaut
    Voilà le code du script en entier,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
     
    #! /usr/bin/perl -w
    use strict;
     
    my @Answer = ();
    my $number = 0;
     
    open(File2,"<mots.txt") or die("Lecture du fichier2 impossible\n");
    while(<File2>)
    {
        my $scrambled = $_;
        #On vire le #
        $scrambled =~m/\w/;
        my $pure = $&.$';#' Commentaire pour fooler emacs ;
        chomp($pure);
        my $regexp = ("[".$pure."]");
        print("*A descrambler : $pure, regexp : $regexp\n");
        open(FILE1,"<wordlist.txt") or die("Lecture du fichier1 impossible\n");   
        while(<FILE1>)
        {
    	chomp($_);
    	my $reg = $regexp;
    	my $word = $_;
    	my $word2 = $_;
    	while($word =~m/^$reg/)
    	{
    	    #On enlève le caractère matché de reg :
    	    my $index = index($reg,$&);
    	    $reg = substr($reg,0,$index).substr($reg,$index+1);
    	    #Si on est pas arrivé à la fin :
    	    if(length($word) != 2)
    	    {
    		#On l'enlève du mot
    		$word = substr($word,1);
    	    }
    	    else
    	    {
    		#On l'ajoute à la réponse
    		$Answer[$number] = $word2;
    		print("$word2\n");
    		last;
    	    }
    	}
        }
        close(FILE1);
        $number++;
    }
    foreach(@Answer)
    {
        $| = 1;
        print($_);
        print(',');
    }
    Voilà le fichier mots.txt
    # slteyan
    # eiabklc
    # ibgatm
    # llnaeide
    # nabwsoll
    # keijca
    # ehnlac
    # tsitenm
    # frlego
    # teelsat
    voilà la sortie standard
    *A descrambler : slteyan, regexp : [slteyan]
    stanley
    *A descrambler : eiabklc, regexp : [eiabklc]
    blackie
    *A descrambler : ibgatm, regexp : [ibgatm]
    gambit
    *A descrambler : llnaeide, regexp : [llnaeide]
    danielle
    daniel
    elaine
    nellie
    *A descrambler : nabwsoll, regexp : [nabwsoll]
    snowball
    snowbal
    *A descrambler : keijca, regexp : [keijca]
    jackie
    *A descrambler : ehnlac, regexp : [ehnlac]
    chanel
    *A descrambler : tsitenm, regexp : [tsitenm]
    mittens
    *A descrambler : frlego, regexp : [frlego]
    golfer
    *A descrambler : teelsat, regexp : [teelsat]
    seattle
    lestat
    ,
    Je ne les ai pas mis dès le début, car je ne voulais pas vous inonder de données.

    La séquence de débuggage de mon premier poste a lieu à la ligne 39.

  4. #4
    Expert confirmé
    Avatar de Jedai
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2003
    Messages
    6 245
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Avril 2003
    Messages : 6 245
    Par défaut
    Et wordlist ?

    --
    Jedaï

  5. #5
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    29
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations forums :
    Inscription : Janvier 2007
    Messages : 29
    Par défaut
    Bon, j'ai bossé un petit peu dessus, et j'ai remis le code comme je l'avais conçu au début (je l'avais modifié pour contourner le problème, mais c'est un échec) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
     
    #! /usr/bin/perl -w
    use strict;
     
    my @Answer = ();
     
    open(File2,"<mots.txt") or die("Lecture du fichier2 impossible\n");
    while(<File2>)
    {
        my $scrambled = $_;
        #On vire le #
        $scrambled =~m/\w/;
        my $pure = $&.$';#' Commentaire pour fooler emacs ;
        chomp($pure);
        my $regexp = ("[".$pure."]");
        print("*A descrambler : $pure, regexp : $regexp\n");
        open(FILE1,"<wordlist.txt") or die("Lecture du fichier1 impossible\n");   
        my $found=0;
        while(<FILE1>)
        {
    	chomp($_);
    	my $reg = $regexp;
    	my $word = $_;
    	my $word2 = $_;
    	while($word =~m/^$reg/)
    	{
    	    #On enlève le caractère matché de reg :
    	    my $index = index($reg,$&);
    	    $reg = substr($reg,0,$index).substr($reg,$index+1);
    	    #Si on est pas arrivé à la fin :
    	    if(length($word) != 2)
    	    {
    		#On l'enlève du mot
    		$word = substr($word,1);
    	    }
    	    else
    	    {
    		#On l'ajoute à la réponse
    		@Answer = (@Answer,$word2);
    		print(join(",",@Answer)."\n");
    		$found = 1;
    		last;
    	    }
    	}
    	if($found)
    	{
    	    last;
    	}
        }
        close(FILE1);
    }
    foreach(@Answer)
    {
        $| = 1;
        print($_);
        print(',');
    }
    Et j'ai fait des tests en plus : quand je réduis le fichier wordlist à ça :
    stanley
    blackie
    gambit
    danielle
    snowball
    jackie
    chanel
    mittens
    golfer
    seattle
    Ca marche impeccable, c'est à dire que la sortie devient

    *A descrambler : slteyan, regexp : [slteyan]
    stanley
    *A descrambler : eiabklc, regexp : [eiabklc]
    stanley,blackie
    *A descrambler : ibgatm, regexp : [ibgatm]
    stanley,blackie,gambit
    *A descrambler : llnaeide, regexp : [llnaeide]
    stanley,blackie,gambit,danielle
    *A descrambler : nabwsoll, regexp : [nabwsoll]
    stanley,blackie,gambit,danielle,snowball
    *A descrambler : keijca, regexp : [keijca]
    stanley,blackie,gambit,danielle,snowball,jackie
    *A descrambler : ehnlac, regexp : [ehnlac]
    stanley,blackie,gambit,danielle,snowball,jackie,chanel
    *A descrambler : tsitenm, regexp : [tsitenm]
    stanley,blackie,gambit,danielle,snowball,jackie,chanel,mittens
    *A descrambler : frlego, regexp : [frlego]
    stanley,blackie,gambit,danielle,snowball,jackie,chanel,mittens,golfer
    *A descrambler : teelsat, regexp : [teelsat]
    stanley,blackie,gambit,danielle,snowball,jackie,chanel,mittens,golfer,seattle
    stanley,blackie,gambit,danielle,snowball,jackie,chanel,mittens,golfer,seattle,
    En revanche, quand il s'agit du fichier complet, à savoir
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
     
    html:)
    121212
    131313
    123123
    654321
    8675309
    666666
    696969
    888888
    1234567
    21122112
    12345678
    asdfjkl;
    hal9000
    bond007
    ncc1701d
    ncc1701e
    ncc1701
    thx1138
    a12345
    abcd1234
    1234qwer
    1a2b3c
    1q2w3e
    test123
    1p2o3i
    puppy123
    kitten12
    qwerty12
    john316
    apollo13
    ne1469
    amanda1
    mazda1
    angela1
    alpha1
    sarah1
    nirvana1
    bubba1
    scuba1
    rambo1
    charlie1
    david1
    digital1
    dragon1
    honda1
    shadow1
    eagle1
    freak1
    james1
    1sanjose
    apple1
    master1
    happy1
    martin1
    jason1
    larry1
    number1
    robert1
    soccer1
    direct1
    chester1
    welcome1
    french1
    hockey1
    chevy1
    scooter1
    chris1
    lucky1
    teddy1
    phoenix1
    hello1
    julie1
    kevin1
    pookie1
    viper1
    jenny1
    jesus1
    kelly1
    money1
    mouse1
    sting1
    justin1
    molly1
    sunny1
    front242
    jordan23
    2welcome
    h2opolo
    bird33
    4runner
    babylon5
    star69
    ib6ub9
    america7
    seven7
    number9
    porsche9
    barbara
    database
    banana
    bananas
    canada
    jamaica
    amanda
    valhalla
    samantha
    yamaha
    natasha
    alaska
    tamara
    zapata
    avatar
    basketba
    baseball
    basebal
    bastard
    nebraska
    banane
    abigail
    sabrina
    batman
    cocacola
    cascade
    cardinal
    claudia
    packard
    cannonda
    apache
    america
    canela
    camera
    caesar
    warcraft
    catalog
    chapman
    zachary
    alicia
    patricia
    carolina
    nicarao
    captain
    nautica
    pascal
    rascal
    camaro
    nascar
    deadhead
    adidas
    alexande
    airhead
    alexandr
    andrea
    gandalf
    grandma
    happyday
    indiana
    paladin
    miranda
    adrian
    dakota
    dallas
    mayday
    pandora
    sandra
    xanadu
    angela
    margaret
    stargate
    savage
    gateway
    athena
    ariane
    pearljam
    maryjane
    oatmeal
    pamela
    pantera
    vanessa
    graymail
    iguana
    jaguar
    galaxy
    gasman
    hannah
    hawaii
    mariah
    jonathan
    marshal
    martha
    nathan
    italia
    aikman
    saskia
    vanilla
    mailman
    animal
    animals
    impala
    attila
    marina
    mariposa
    nirvana
    arizona
    joanna
    january
    lakota
    avalon
    alyssa
    yomama
    montana
    mantra
    tazman
    tarzan
    starwars
    bobcat
    badboy
    barbie
    babies
    basketb
    rabbit
    bamboo
    rebecca
    abcdef
    abcdefg
    blackie
    excalibu
    campbell
    tacobell
    bigmac
    jsbach
    columbia
    buddha
    badger
    butthead
    bradley
    brenda
    bernard
    ladybug
    diablo
    blizzard
    brandi
    bandit
    brandon
    brandy
    beagle
    isabelle
    elizabet
    beanie
    beatles
    webmaste
    beaner
    beaver
    fireball
    beautifu
    gabriell
    gabriel
    poohbear
    bertha
    benjamin
    bailey
    beavis
    basket
    blaster
    albert
    blazer
    barney
    strawber
    braves
    buffalo
    football
    softball
    footbal
    foobar
    bigman
    gambit
    global
    malibu
    library
    brasil
    brazil
    rainbow
    obiwan
    kombat
    snowball
    marlboro
    snowbal
    playboy
    absolut
    wombat
    canced
    icecream
    chance
    celica
    cracker
    cancer
    access
    pacific
    chicago
    chocolat
    arctic
    clancy
    cactus
    dickhead
    maddock
    medical
    claude
    sundance
    dancer
    crawford
    richard
    wildcat
    picard
    colorado
    conrad
    corrado
    changeme
    chelsea
    peaches
    research
    teachers
    teacher
    creative
    cleaner
    france
    challeng
    michael
    charlie
    archie
    hacker
    chanel
    rachel
    charles
    patches
    jackie
    janice
    jessica
    maverick
    metallic
    caroline
    special
    claire
    iceman
    maurice
    maveric
    veronica
    carrie
    cassie
    active
    slacker
    packer
    packers
    marcel
    coltrane
    carole
    lacrosse
    scarlet
    scarlett
    castle
    carmen
    pacers
    racerx
    stacey
    catfish
    californ
    francois
    francis
    falcon
    graphic
    logical
    garlic
    camping
    racing
    cougars
    cougar
    chiquita
    christia
    nicholas
    champion
    cynthia
    charity
    charlott
    champs
    caitlin
    victoria
    tricia
    patrick
    calvin
    monica
    macintos
    action
    picasso
    jackson
    malcolm
    coolman
    classroo
    carlos
    crystal
    compaq
    tomcat
    marcus
    cannon
    corona
    cyrano
    topcat
    tractor
    laddie
    undead
    edward
    maddog
    diamond
    donald
    woodland
    greenday
    danielle
    dreamer
    reader
    garfield
    alfred
    reading
    gerald
    garden
    shithead
    daniel
    ireland
    raider
    raiders
    daytek
    leonard
    dreams
    anderson
    darren
    sanders
    andrew
    retard
    tuesday
    asdfghjk
    asdfgh
    dragonfl
    florida
    friday
    asdfjkl
    digital
    godzilla
    douglas
    dragon
    harold
    rhonda
    zaphod
    howard
    shadows
    shadow
    thursday
    indian
    island
    lindsay
    lizard
    madison
    pyramid
    darwin
    tardis
    wizard
    majordom
    jordan
    dollars
    orlando
    portland
    ronald
    rodman
    raymond
    monday
    sunday
    password
    passwd
    jeanette
    sweetpea
    jaeger
    general
    eagles
    heather
    kathleen
    hawkeye
    elephant
    sheena
    theresa
    theatre
    whatever
    whateve
    amelie
    melanie
    elaine
    valerie
    jeanne
    yankees
    walleye
    please
    seattle
    weasel
    awesome
    netware
    teresa
    grateful
    frankie
    fireman
    ferrari
    farmer
    safety
    maggie
    georgia
    aggies
    imagine
    galileo
    goalie
    enigma
    mirage
    wrangler
    angels
    german
    orange
    oranges
    ranger
    garnet
    voyager
    garrett
    target
    health
    katherin
    sheila
    stephani
    sapphire
    asshole
    harley
    stealth
    whales
    ashley
    hammer
    herman
    theman
    hamster
    matthew
    panther
    hearts
    harvey
    jasmine
    mikael
    mailer
    melissa
    valentin
    lorraine
    alpine
    aliens
    tequila
    reality
    laurie
    alexis
    sammie
    maxime
    marine
    vampire
    insane
    painter
    petunia
    praise
    pirate
    sierra
    asterix
    xavier
    jasper
    lakers
    walker
    kramer
    market
    tanker
    wanker
    parker
    startrek
    skater
    maxwell
    stella
    montreal
    temporal
    sampler
    marley
    samuel
    napoleon
    espanol
    snapple
    planet
    lauren
    stanley
    apples
    players
    player
    raquel
    slayer
    travel
    walter
    lestat
    superman
    masters
    master
    tanner
    suzanne
    newpass
    peanut
    warren
    tiffany
    wolfgang
    flamingo
    farming
    fugazi
    franklin
    family
    fountain
    wolfman
    smashing
    virginia
    sailing
    training
    stingray
    giants
    guitar
    magnum
    morgan
    mustang
    gymnast
    august
    mishka
    harrison
    spanish
    shanti
    joshua
    kathryn
    shalom
    hansolo
    phantom
    thomas
    shannon
    hanson
    anthony
    sharon
    hatton
    author
    arthur
    nikita
    williams
    william
    raistlin
    olivia
    julian
    jasmin
    allison
    marilyn
    alison
    polaris
    sailor
    quality
    sylvia
    ironman
    mountain
    tinman
    marino
    martin
    marvin
    matrix
    nissan
    passion
    station
    tristan
    austin
    utopia
    warriors
    warrior
    artist
    travis
    krystal
    spanky
    sparky
    apollo
    salmon
    psalms
    larson
    royals
    taylor
    norman
    snowman
    sampson
    samson
    mozart
    watson
    saturn
    tattoo
    toyota
    sparrow
    parrot
    passwor
    qwaszx
    stuart
    taurus
    bubbles
    debbie
    bluebird
    bigbird
    pebbles
    robbie
    hobbit
    jimbob
    booboo
    december
    quebec
    robotech
    republic
    october
    public
    zxcvbnm
    broncos
    cowboys
    scooby
    cowboy
    firebird
    bigred
    bridges
    dogbert
    thunderb
    birdie
    blondie
    dilbert
    doobie
    blonde
    rosebud
    bigdog
     
     
    bulldog
    sunbird
    remember
    septembe
    homebrew
    herbert
    biteme
    bernie
    reebok
    rebels
    byteme
    brewster
    webster
    boogie
    junebug
    goblue
    goober
    shelby
    theboss
    kimberly
    zombie
    timber
    bonnie
    benoit
    business
    nesbitt
    bootsie
    bluesky
    brooke
    volleyb
    bullet
    blowme
    trouble
    butler
    boomer
    benson
    booster
    trebor
    buster
    bigfoot
    blowfish
    bright
    bowling
    biology
    gibson
    bullshit
    robinhoo
    bookit
    wilbur
    bonjour
    symbol
    boston
    browns
    buttons
    button
    brutus
    cccccc
    electric
    science
    chicken
    cricket
    celtics
    cyclone
    connect
    concept
    soccer
    success
    church
    chucky
    scotch
    cloclo
    cuddles
    depeche
    mercedes
    frederic
    deutsch
    duckie
    wicked
    cinder
    director
    orchid
    dominic
    doctor
    cheese
    coffee
    fletcher
    gretchen
    college
    michelle
    michele
    speech
    chester
    celine
    eclipse
    pierce
    service
    colleen
    telecom
    welcome
    spencer
    center
    except
    secret
    chiefs
    fletch
    fuckme
    fucker
    michell
    mitchell
    michel
    chipper
    hockey
    cheryl
    techno
    porsche
    hector
    cherry
    justice
    pickle
    mickey
    snicker
    snickers
    cookie
    cookies
    nicole
    police
    clipper
    mexico
    connie
    vincent
    prince
    princess
    picture
    pisces
    security
    cruise
    rocket
    puckett
    tucker
    clover
    computer
    compute
    mercury
    newcourt
    courtney
    cooper
    scooter
    coyote
    copper
    fuckoff
    scruffy
    fiction
    fuckyou
    gocougs
    christin
    christop
    chrissy
    christ
    christy
    school
    psycho
    politics
    knicks
    lincoln
    unicorn
    scorpion
    corwin
    sonics
    scorpio
    victor
    victory
    curtis
    trucks
    control
    compton
    moocow
    cosmos
    popcorn
    xcountry
    country
    scotty
    deedee
    dundee
    freddy
    dodger
    dodgers
    defense
    freedom
    fender
    legend
    deliver
    denise
    kennedy
    ledzep
    denver
    speedo
    speedy
    dexter
    friend
    friends
    doggie
    digger
    goldie
    redwing
    design
    doogie
    dougie
    golden
    hendrix
    thunder
    inside
    kinder
    redskin
    dookie
    lindsey
    dennis
    trident
    sendit
    sidney
    detroit
    spider
    strider
    donkey
    reynolds
    elwood
    redrum
    wonder
    notused
    student
    sydney
    windsurf
    oxford
    midnight
    dwight
    hotdog
    indigo
    kingdom
    snoopdog
    gordon
    phurivdli
    judith
    dolphin
    dolphins
    hotrod
    dorothy
    midori
    skidoo
    domino
    nimrod
    wisdom
    windows
    dustin
    stupid
    drizzt
    london
    studly
    voodoo
    peewee
    reefer
    eugene
    sweetie
    kleenex
    skeeter
    penelope
    steelers
    steele
    eeyore
    weezer
    jeffrey
    jennifer
    jenifer
    ferret
    reggie
    george
    wheeling
    genesis
    sergei
    energy
    hershey
    kenneth
    shelley
    helpme
    wheels
    promethe
    hermes
    stephen
    einstein
    jessie
    nellie
    leslie
    letmein
    zeppelin
    etoile
    nemesis
    internet
    pierre
    jewels
    jeremy
    jensen
    jester
    kelsey
    loveme
    people
    explorer
    wrestle
    letter
    wesley
    velvet
    western
    newuser
    steven
    popeye
    europe
    pepper
    express
    tester
    stever
    testtest
    sweets
    sweety
    tweety
    griffey
    golfer
    fisher
    spitfire
    flipper
    xfiles
    fozzie
    sunflowe
    flowers
    flower
    flyers
    forest
    surfer
    future
    ginger
    tigger
    google
    nugget
    gregory
    theking
    gopher
    gemini
    gilles
    piglet
    penguin
    guinness
    singer
    testing
    genius
    tigers
    gretzky
    gunner
    nguyen
    grover
    shirley
    memphis
    sunshine
    phoenix
    whitney
    zenith
    hootie
    sophie
    joseph
    huskers
    shelly
    mother
    thumper
    hornets
    hornet
    hunter
    shooter
    topher
    horses
    zephyr
    sherry
    millie
    willie
    olivier
    minnie
    winnie
    trixie
    jupiter
    killme
    killer
    mookie
    kermit
    kristen
    tinker
    kittens
    kitten
    pookie
    skipper
    miller
    soleil
    elliot
    little
    merlin
    simple
    smiles
    smiley
    online
    wolverin
    liverpoo
    iloveyou
    oliver
    louise
    violet
    silver
    sylvie
    mortimer
    swimmer
    emmitt
    monique
    pentium
    mittens
    niners
    intern
    winner
    tennis
    senior
    sniper
    sunrise
    winter
    tootsie
    puppies
    ripper
    sprite
    monkey
    smokey
    network
    newyork
    volley
    yellow
    russell
    lennon
    nelson
    looney
    loveyou
    protel
    wolves
    purple
    russel
    turtle
    memory
    summer
    monster
    vermont
    trumpet
    system
    newton
    yvonne
    runner
    preston
    entropy
    reznor
    sunset
    rooster
    property
    porter
    export
    trevor
    qwerty
    fluffy
    muffin
    snuffy
    golfing
    froggy
    kingfish
    fishing
    flight
    gofish
    goforit
    informix
    pinkfloy
    foxtrot
    frosty
    zhongguo
    knights
    knight
    nothing
    hunting
    wright
    shotgun
    lionking
    skiing
    vikings
    viking
    swimming
    running
    roping
    spring
    grumpy
    topgun
    groovy
    phillip
    philip
    whisky
    timothy
    smiths
    sunshin
    horizon
    history
    johnson
    johnny
    murphy
    houston
    python
    shorty
    kristin
    kristi
    million
    mission
    tintin
    vision
    spirit
    junior
    justin
    pumpkin
    punkin
    skinny
    stinky
    skippy
    kristy
    suzuki
    willow
    wilson
    moroni
    mirror
    morris
    stimpy
    winston
    poiuyt
    squirt
    spunky
    spooky
    monopoly
    molson
    moomoo
    stormy
    toronto
    snoopy
    support
    sports
    Ca donne :

    *A descrambler : slteyan, regexp : [slteyan]
    stanley
    *A descrambler : eiabklc, regexp : [eiabklc]
    ,blackie
    *A descrambler : ibgatm, regexp : [ibgatm]
    ,gambite
    *A descrambler : llnaeide, regexp : [llnaeide]
    ,danielle
    *A descrambler : nabwsoll, regexp : [nabwsoll]
    ,snowball
    *A descrambler : keijca, regexp : [keijca]
    ,jackiell
    *A descrambler : ehnlac, regexp : [ehnlac]
    ,chanelll
    *A descrambler : tsitenm, regexp : [tsitenm]
    ,mittensl
    *A descrambler : frlego, regexp : [frlego]
    ,golfersl
    *A descrambler : teelsat, regexp : [teelsat]
    ,seattlel
    ,%

    En débuggant ce dernier cas, je suis tombé sur un problème totalement hérmétique pour moi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
     
    Current directory is /Users/edouard/Desktop/HTS/
     
    Loading DB routines from perl5db.pl version 1.28
    Editor support enabled.
     
    Enter h or `h h' for help, or `man perldebug' for more help.
     
      DB<1> b 38
      DB<2> c
    *A descrambler : slteyan, regexp : [slteyan]
      DB<2> s
      DB<2> s
    stanley
      DB<2> c
    *A descrambler : eiabklc, regexp : [eiabklc]
      DB<2> p @Answer
    stanley
      DB<3> s
      DB<3> p @Answer
    blackie
    [...]
      DB<5> p $Answer[0]
    stanley
      DB<6> p $Answer[1]
    blackie
      DB<7> s
    ,blackie
      DB<7>
    Le problème est à la ligne 38 :
    @Answer = (@Answer,$word2);
    print(join("'",@Answer)."\n");

    Bien que, comme le montre le débugger, @Answer soit égal à (stanley,blackie), la ligne avec le print n'affiche que ,blackie.

    Je n'ai pas la moindre idée d'où vient ce problème, c'est de la magie pour moi.

  6. #6
    Expert confirmé
    Avatar de Jedai
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2003
    Messages
    6 245
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Avril 2003
    Messages : 6 245
    Par défaut
    [EDIT] J'ai trouvé : il y a des \r (retour chariot) qui se baladent dans tes fichiers et ne sont pas supprimés par ton chomp() (problème de plateforme/mode de lecture, je suppose que tu es sous Unix et que la liste vient de Windows), du coup ton join écrit "stanley\r, blackie\r" sur le terminal, or "\r" déclenche le retour du curseur au début de la ligne et blackie est écrit "sur" stanley, ça se voit particulièrement bien avec snowball et jackie (regarde, il y a "jackiell" d'écrit parce que snowball est plus long). Perldb t'aurais permis de le voir si tu avais utilisé "x" plutôt que "p", car p affiche une chaîne de caractère, alors que x fait un dump, où les caractères spéciaux sont visibles. Tu devrais nettoyer ta liste de mot (dos2unix).
    Que ça ne t'empêche pas par ailleurs d'adopter plutôt ma solution, elle est meilleure algorithmiquement.

    Bon, je ne sais pas vraiment ce qui se passe dans ton code, mais ton algorithme semble vraiment mauvais, je te propose la solution suivante en remplacement, elle est bien plus performante et simple (et marche avec la liste complète de mots) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    #!/usr/bin/perl
    use strict; use warnings;
     
    # data input
    my $wl_name = 'wordlist.txt';
    my $swl_name = 'mots.txt';
     
    # building our descrambler
    open my($wordlist), '<', $wl_name
      or die "Can't open $wl_name : $!\n";
    my @list_safe_words = <$wordlist>;
    chomp @list_safe_words;
    my %words = 
      map { (join q(), sort (split //)) => $_ } @list_safe_words;
     
    # main descrambling loop
    my @answer;
    open my($scrambled), '<', $swl_name
      or die "Can't open $swl_name : $!\n";
    while( <$scrambled> ) {
      chomp;
      s/^#\s*//;
      my $sorted = join q(), sort (split //);
      if( exists $words{$sorted} ){
        push @answer, $words{$sorted};
        print +(join q(,), @answer), "\n";
      }
    }
    (Par ailleurs, utilise plutôt le mode CPerl avec Emacs que le mode Perl, il est bien meilleur et ne se laissera pas perturber par une petite chose comme $')

    --
    Jedaï

Discussions similaires

  1. Programmer encore en VB 6 c'est pas bien ? Pourquoi ?
    Par Nektanebos dans le forum Débats sur le développement - Le Best Of
    Réponses: 85
    Dernier message: 10/03/2009, 14h43
  2. Mon script cron n'est pas pris en compte
    Par tomnie dans le forum Linux
    Réponses: 11
    Dernier message: 31/03/2004, 11h19
  3. LIKE de tout ce qui n'est pas compris entre a<-&
    Par DjinnS dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 28/07/2003, 13h09
  4. [VB6] générer un recordset qui n'est pas lier à un bdd
    Par damyrid dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 05/06/2003, 17h48
  5. Index n'est pas a jour
    Par touhami dans le forum Paradox
    Réponses: 5
    Dernier message: 11/12/2002, 14h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo