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

Programmation et administration système Perl Discussion :

migration code perl v5.14.2 vers perl v5.28.6


Sujet :

Programmation et administration système Perl

  1. #1
    Candidat au Club
    Homme Profil pro
    Administrateur système
    Inscrit en
    Avril 2020
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur système
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Avril 2020
    Messages : 2
    Points : 3
    Points
    3
    Par défaut migration code perl v5.14.2 vers perl v5.28.6
    Bonjour,

    je suis en train de refaire mon code perl en version v5.14.2, j'ai une erreur de ce type
    Experimental each on scalar is now forbidden at jdoodle.pl line 142.
    Type of arg 1 to each must be hash or array (not hash element) at jdoodle.pl line 142, near "}) "
    Execution of jdoodle.pl aborted due to compilation errors.
    Command exited with non-zero status 255
    voici mon code
    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
    #!/usr/bin/perl -w
    #
    # bb-TEMPLATE - template for a Big Brother add-on
    # cgoyard
     
    use strict;
    use Data::Dumper;
     
    my $DEBUG       = 0;
     
    #------------------------------------------------------------------------------------------------------------
    # VARIABLES MODIFIABLES
    #--------------------------------------------------------------------------------------------------------
    my $hostname =  `hostname -f`;
    chomp $hostname;
     
     
     
    my $BB          = $ENV{BB};     # full path to the bin/bb util
    my $BBDISP      = $ENV{BBDISP};     # IP of the BBDISPLAY server
     
     
    #my $BB = "/usr/lib/hobbit/client/bin/bb"; 
    #my $BBDISP = "10.3.254.1"  ; 
    #my $BBTMP = "/var/lib/hobbit/tmp";
     
     
    my $date = `date`; chomp $date;
    my $test = "Import_kpi";
     
    my $color = "green";
    my $message = "Suivi des import dans Hybris\n";
    my $status ;
     
    my $tab_bgcolor = "#6E6E6E";
    my $tab_width   = "100%";
    my $tab_header  = "border=1 cellspacing='1' cellpadding='1' width=$tab_width align=center";
    my $td_header   = "style='background-color:\"#FF8000\";font-weight: bold;font-size:19;color:black;'";
    my $image_green='<IMG SRC="/xymon/gifs/green.gif" ALT="green" HEIGHT="16" WIDTH="16" BORDER=0>';
    my $image_red='<IMG SRC="/xymon/gifs/red.gif" ALT="red" HEIGHT="16" WIDTH="16" BORDER=0>';
    my $image_yellow='<IMG SRC="/xymon/gifs/yellow.gif" ALT="yellow" HEIGHT="16" WIDTH="16" BORDER=0>';
     
     
    my %test_names = ();
    my %tableau = ();
    my $i=0;
    my %namembeans = (1,"BirdDeliveryMode",
    2,"BirdDeliveryCalendar",
    3,"ZoneDeliveryValue_piece",
    4,"ZoneDeliveryValue_weight",
    5,"ImageBrand",
    6,"ImageBrandAssignment",
    7,"ImagePictos",
    8,"SupplyMode",
    9,"ImagePictosAssignment",
    10,"MainImageProducts",
    11,"MainImageProductsAssignment",
    12,"GalleryImageProducts",
    13,"GalleryImageProductsAssignment",
    14,"BirdBrand",
    15,"ClassificationAttributeUnit",
    16,"ClassificationClass",
    17,"ClassificationAttribute",
    18,"ClassificationAttributeAssignement",
    19,"BirdProduct",
    20,"BirdVariantProduct",
    21,"BirdColorVariantDimension",
    22,"BirdSizeVariantDimension",
    23,"ArticleDefaultVariant",
    24,"BirdBundle",
    25,"BirdBundleComponent",
    26,"BirdProductSet",
    27,"ProductReference",
    28,"Categoryattachement",
    29,"CategoryProductRelation",
    30,"ProductFeature",
    31,"ProductFeatureFilter",
    32,"PriceRow",
    33,"BirdTaxParticipationRow",
    34,"BirdPackage",
    35,"BirdProductPackages",
    36,"BirdProductSupplyModes",
    37,"BirdProductDeliveryModes",
    38,"ecat_stocklevel",
    39,"Import MR",
    41,"Proximit&eacute; MR",
    42,"Import Maxxing",
    43,"Export Attribut Pertimm",
    44,"Export Product Pertimm",
    45,"Import Express",
    46,"Proximit&eacute; Express",
    47,"Batch d'import des op&eacute;rations commerciales",
    48,"Batch d'import des relations produits <> offres",
    49,"Batch d'import des relations cat&eacute;gories <> offres",
    50,"Synchronisation Produits",
    51,"Indexation SolR",
    52,"Bazaarvoice Importer",
    53,"Bazaarvoice Exporter",
    54,"PaymentFacilityImport",
    1000,"AutomatedProductRankingImport");
     
     
     
     
     my $infos = `sudo -u hybris /usr/local/lib/jmx/launch.sh`;
     my @values = split("\n", $infos);
     
    $message = $message."<table $tab_header><td align=center $td_header ><center>Id</center></td>
                                            <td align=center $td_header><center>Mbeans</enter></td>
                                            <td align=center $td_header><center>R&eacute;sultat d'int&eacute;gration</center></td>
                                            <td align=center $td_header><center>Pourcentage de lignes int&eacute;gr&eacute;es</center></td>
                                            <td align=center $td_header><center>Nombre de lignes dans le fichie</center></td>
                                            <td align=center $td_header><center>Temps d'int&eacute;gration</center></td>
                                            <td align=center $td_header><center>Date de d&eacute;marrage d'int&eacute;gration</center></td>
                                            <td align=center $td_header><center>Date de fin d'int&eacute;gration</center></td>
                                            <td align=center $td_header<center>Statut d'int&eacute;gration</center></td>";
     
     foreach my $val (@values) {
      if ($val =~ "Import_kpi") { 
     
         #print $val."  test \n";
     
         my @test_name_color_with_ncv_line = split("\\ ", $val, 2);
         my $test_name = $test_name_color_with_ncv_line[0];
         my $color_with_ncv_line  = $test_name_color_with_ncv_line[1];
     
        # print $color_with_ncv_line."\n"; 
     
               if ( $color_with_ncv_line  =~ /^(\d+\.?):(\D+):([A-Z].*)/ ) {push ( @{$tableau{$1}}, $3);}
              # elsif ( $color_with_ncv_line  =~ /^(\d+\.?):(\D+):(\d+)/ ) {$message=$message."<td>$1</td><td>$3</td>"}
               elsif ( $color_with_ncv_line  =~ /^(\d+\.?):(\D+):(\d+)/ ) {push ( @{$tableau{$1}}, $3);}
      }
     }
    #print Dumper \%tableau;
     
    foreach my $valt (sort {$a <=> $b} keys %tableau) { 
     
      #print "val => ".$valt."\n";
      $status .= $namembeans{$valt}.": ";
      $message=$message."<tr align=center><td> $valt </td><td> $namembeans{$valt} </td>";
     
       while( my ($k,$v) = each($tableau{$valt}) ) {
              if ($v eq "OK") {$v = "$image_green   OK ";}   
              if ($v eq "WARNING") {$v = "$image_yellow WARNING ";}   
              if ($v eq "CRITICAL") {$v = "$image_red CRITICAL ";}   
              $message=$message."<td> $v </td>";
    			if ( $k ==3 ) {
    		  		$status .= $v."\n";	
    			}
        }
      $message=$message."</tr>";
    } 
     
    $message=$message."</tables>";
    #$status .= "";
     
    # Envoie au serveur 
    my $cmd = " $BB $BBDISP \"status $hostname.$test $color $date <HR> $message\n\n 
    <!--
    $status-->
    \n\"";
     
    #print $cmd;
    system($cmd);
    l'erreur dans la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    while( my ($k,$v) = each($tableau{$valt}) ) {
    merci pour votre aide

  2. #2
    Expert éminent Avatar de CosmoKnacki
    Homme Profil pro
    Justicier interdimensionnel
    Inscrit en
    Mars 2009
    Messages
    2 858
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Justicier interdimensionnel

    Informations forums :
    Inscription : Mars 2009
    Messages : 2 858
    Points : 6 556
    Points
    6 556
    Par défaut
    C'est simple $tableau{$valt} n'est pas une liste mais une référence vers une liste.

    La version v5.14 autorise cet abus de langage:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    while ( my ($k, $v) = each($tableau{$valt}) )
    où bien qu'une référence soit passée à la fonction each() elle n'en renvoie pas moins une liste avec l'index et la valeur de chaque item.
    Cette facilité a été abandonnée avec la version 5.24 et il faut donc passer à each() non pas une référence mais bien sa cible, la liste elle-même:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    while ( my ($k, $v) = each(@{$tableau{$valt}}) )
    Tu peux retrouver cette information dans le perldoc.
    Brachygobius xanthozonus
    Ctenobrycon Gymnocorymbus

  3. #3
    Candidat au Club
    Homme Profil pro
    Administrateur système
    Inscrit en
    Avril 2020
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Administrateur système
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Avril 2020
    Messages : 2
    Points : 3
    Points
    3
    Par défaut
    merci bcp, ça marche

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. explication sur un code perl
    Par Melvine dans le forum Langage
    Réponses: 5
    Dernier message: 05/10/2006, 16h32
  2. pb code perl
    Par visteur dans le forum Langage
    Réponses: 3
    Dernier message: 06/03/2006, 09h43
  3. Réponses: 1
    Dernier message: 29/11/2005, 22h05
  4. [langage] code Perl
    Par GMI3 dans le forum Langage
    Réponses: 3
    Dernier message: 18/03/2004, 11h26

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