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 :

Probleme fonction qw


Sujet :

Langage Perl

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Inscrit en
    Mai 2010
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 24
    Par défaut Probleme fonction qw
    Bonjour,
    J'ai un problème concernant la fonction qw.
    Voici mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    my @bw1 = qw(
    10 30 50 120 230 400
    );
    Je souhaiterais remplacer 10,30,50.. par des variables.
    Mais ce code la ne marche pas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    my @bw1 = qw(
    $resu1 $resu2 $resu3 $resu4 $resu5 $resu6
    );
    Merci d'avance.

  2. #2
    Expert confirmé

    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2009
    Messages
    3 577
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Avril 2009
    Messages : 3 577
    Par défaut
    Utilise donc simplement :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    my @bw1 = (
    $resu1, $resu2, $resu3, $resu4, $resu5, $resu6
    );
    L'opérateur qw{} n'a d'utilité que pour créer une liste à partir d'une chaine de caractère, sans interpolation (afin justement de préserver $, par exemple, pour définir une liste de variable à importer d'un module).

  3. #3
    Membre averti
    Homme Profil pro
    Inscrit en
    Mai 2010
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 24
    Par défaut
    Merci de ta réponse, j'ai déjà essayé mais sans succès :
    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
    Number found where operator expected at histo.pl line 17, near "1 2"
    	(Missing operator before  2?)
    Number found where operator expected at histo.pl line 17, near "2 3"
    	(Missing operator before  3?)
    Number found where operator expected at histo.pl line 17, near "3 4"
    	(Missing operator before  4?)
    Number found where operator expected at histo.pl line 17, near "4 5"
    	(Missing operator before  5?)
    Number found where operator expected at histo.pl line 17, near "5 6"
    	(Missing operator before  6?)
    Number found where operator expected at histo.pl line 17, near "6 7"
    	(Missing operator before  7?)
    Number found where operator expected at histo.pl line 17, near "7 8"
    	(Missing operator before  8?)
    Number found where operator expected at histo.pl line 17, near "8 9"
    	(Missing operator before  9?)
    Number found where operator expected at histo.pl line 17, near "9 10"
    	(Missing operator before  10?)
    Number found where operator expected at histo.pl line 17, near "10 11"
    	(Missing operator before  11?)
    Number found where operator expected at histo.pl line 17, near "11 12"
    	(Missing operator before  12?)
    Number found where operator expected at histo.pl line 20, near "5.8 5.0"
    	(Missing operator before  5.0?)
    Number found where operator expected at histo.pl line 20, near "5.0 4.9"
    	(Missing operator before  4.9?)
    Number found where operator expected at histo.pl line 20, near "4.9 4.8"
    	(Missing operator before  4.8?)
    Number found where operator expected at histo.pl line 20, near "4.8 4.5"
    	(Missing operator before  4.5?)
    Number found where operator expected at histo.pl line 20, near "4.5 4.25"
    	(Missing operator before  4.25?)
    Number found where operator expected at histo.pl line 20, near "4.25 3.5"
    	(Missing operator before  3.5?)
    Number found where operator expected at histo.pl line 20, near "3.5 2.9"
    	(Missing operator before  2.9?)
    Number found where operator expected at histo.pl line 20, near "2.9 2.5"
    	(Missing operator before  2.5?)
    Number found where operator expected at histo.pl line 20, near "2.5 1.8"
    	(Missing operator before  1.8?)
    Number found where operator expected at histo.pl line 23, near ".7 1.1"
    	(Missing operator before  1.1?)
    Number found where operator expected at histo.pl line 23, near "1.1 1.7"
    	(Missing operator before  1.7?)
    Number found where operator expected at histo.pl line 23, near "1.7 2.5"
    	(Missing operator before  2.5?)
    Number found where operator expected at histo.pl line 23, near "2.5 3.0"
    	(Missing operator before  3.0?)
    Number found where operator expected at histo.pl line 23, near "3.0 4.5"
    	(Missing operator before  4.5?)
    Number found where operator expected at histo.pl line 23, near "4.5 5.0"
    	(Missing operator before  5.0?)
    Number found where operator expected at histo.pl line 23, near "5.0 4.9"
    	(Missing operator before  4.9?)
    Number found where operator expected at histo.pl line 23, near "4.9 4.7"
    	(Missing operator before  4.7?)
    Number found where operator expected at histo.pl line 23, near "4.7 4.8"
    	(Missing operator before  4.8?)
    Number found where operator expected at histo.pl line 23, near "4.8 4.2"
    	(Missing operator before  4.2?)
    Number found where operator expected at histo.pl line 23, near "4.2 4.4"
    	(Missing operator before  4.4?)
    Number found where operator expected at histo.pl line 26, near ".3 1.4"
    	(Missing operator before  1.4?)
    Number found where operator expected at histo.pl line 26, near "1.4 1.2"
    	(Missing operator before  1.2?)
    Number found where operator expected at histo.pl line 26, near "1.2 1.5"
    	(Missing operator before  1.5?)
    Number found where operator expected at histo.pl line 26, near "1.5 4.0"
    	(Missing operator before  4.0?)
    Number found where operator expected at histo.pl line 26, near "4.0 3.5"
    	(Missing operator before  3.5?)
    Number found where operator expected at histo.pl line 26, near "3.5 2.0"
    	(Missing operator before  2.0?)
    Number found where operator expected at histo.pl line 26, near "2.0 1.9"
    	(Missing operator before  1.9?)
    Number found where operator expected at histo.pl line 26, near "1.9 2.7"
    	(Missing operator before  2.7?)
    Number found where operator expected at histo.pl line 26, near "2.7 4.2"
    	(Missing operator before  4.2?)
    Number found where operator expected at histo.pl line 26, near "4.2 3.2"
    	(Missing operator before  3.2?)
    Number found where operator expected at histo.pl line 26, near "3.2 1.1"
    	(Missing operator before  1.1?)
    syntax error at histo.pl line 17, near "1 2"
    syntax error at histo.pl line 20, near "5.8 5.0"
    syntax error at histo.pl line 23, near ".7 1.1"
    syntax error at histo.pl line 26, near ".3 1.4"
    Execution of histo.pl aborted due to compilation errors.
    Je vous met 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
    #!/usr/bin/perl
    use strict;
     
    use Chart::Clicker;
    use Chart::Clicker::Context;
    use Chart::Clicker::Data::DataSet;
    use Chart::Clicker::Data::Marker;
    use Chart::Clicker::Data::Series;
    use Chart::Clicker::Renderer::Area;
    use Geometry::Primitive::Rectangle;
    use Graphics::Color::RGB;
    use Geometry::Primitive::Circle;
     
    my $cc = Chart::Clicker->new(width => 500, height => 250, format => 'png');
     
    my @hours = qw(
    1 2 3 4 5 6 7 8 9 10 11 12
    );
    my @bw1 = qw(
    5.8 5.0 4.9 4.8 4.5 4.25 3.5 2.9 2.5 1.8 .9 .8
    );
    my @bw2 = qw(
    .7 1.1 1.7 2.5 3.0 4.5 5.0 4.9 4.7 4.8 4.2 4.4
    );
    my @bw3 = qw(
    .3 1.4 1.2 1.5 4.0 3.5 2.0 1.9 2.7 4.2 3.2 1.1
    );
     
    my $series1 = Chart::Clicker::Data::Series->new(
        keys => \@hours,
        values => \@bw1,
    );
    my $series2 = Chart::Clicker::Data::Series->new(
        keys => \@hours,
        values => \@bw2,
    );
     
    my $series3 = Chart::Clicker::Data::Series->new(
        keys => \@hours,
        values => \@bw3,
    );
     
    my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series1, $series2, $series3 ]);
     
    $cc->title->text('Area Chart');
    $cc->title->padding->bottom(5);
    $cc->add_to_datasets($ds);
     
    my $defctx = $cc->get_context('default');
     
    my $area = Chart::Clicker::Renderer::Area->new(opacity => .6);
    $area->brush->width(3);
    $defctx->renderer($area);
     
    $defctx->range_axis->label('Lorem');
    $defctx->domain_axis->label('Ipsum');
     
    $defctx->renderer->brush->width(2);
     
    $cc->write_output('area.png');

  4. #4
    Expert confirmé

    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2009
    Messages
    3 577
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Avril 2009
    Messages : 3 577
    Par défaut
    1- ton code semble incohérent avec les erreurs que tu indiques (tu utilises encore qw(...)
    2- tu sembles avoir mal lu ce que j'ai écris, car les erreurs que tu présentes ressemblent à celle que tu aurais pu écrire avec cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    my @hours = (
    1 2 3 4 5 6 7 8 9 10 11 12
    );
    (sans virgule entre les nombres)

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

Discussions similaires

  1. [XSL]Probleme fonction recursive
    Par Le-Cortex dans le forum XSL/XSLT/XPATH
    Réponses: 9
    Dernier message: 12/12/2005, 15h10
  2. [Mail] Probleme fonction mail()
    Par tissot dans le forum Langage
    Réponses: 1
    Dernier message: 14/11/2005, 12h55
  3. problème fonctions callback
    Par youp_db dans le forum GTK+ avec C & C++
    Réponses: 1
    Dernier message: 02/10/2005, 14h47
  4. probleme fonction gethostbyname
    Par oclone dans le forum Développement
    Réponses: 6
    Dernier message: 14/04/2005, 10h31
  5. probleme fonction syntaxe
    Par gIch dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 28/02/2005, 09h52

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