hash

Discussion in 'Perl Misc' started by Tad J McClellan, Feb 24, 2008.

  1. Newsgroups <> wrote:
    > Hi everybody,
    >
    > I can't make sense of my little perl script ; I've no idea where the
    > probleme is... could you give me a way to understand...
    >
    > I've this short code :
    > use strict;
    > use Data::Dumper;
    > use Lingua::Identify qw/:language_identification/;
    >
    > my %probabilities;
    > my %languages = langof_file("test.txt");
    >
    > print Dumper(%languages);
    >
    > it print the text in the console :
    > $VAR1 = 'pt';
    > $VAR2 = '0.0299573389196567';
    > $VAR3 = 'tr';
    > $VAR4 = '0.0152319153730931';
    > $VAR5 = 'da';
    > $VAR6 = '0.0359140188331814';
    > .../...
    >
    >
    > But, I want an output like this one :
    >
    > $VAR1 = {
    > 'pt' => '0.0299573389196567',
    > 'tr' => '0.0152319153730931',
    > 'es' => '0.0403864688211945',
    > 'da' => '0.0359140188331814',
    > };
    >
    > What's wrong ?



    Pass Dumper() a reference rather than a list of keys and values:

    print Dumper \%languages;



    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Feb 24, 2008
    #1
    1. Advertising

  2. Tad J McClellan

    Newsgroups Guest

    Hi everybody,

    I can't make sense of my little perl script ; I've no idea where the
    probleme is... could you give me a way to understand...

    I've this short code :
    use strict;
    use Data::Dumper;
    use Lingua::Identify qw/:language_identification/;

    my %probabilities;
    my %languages = langof_file("test.txt");

    print Dumper(%languages);

    it print the text in the console :
    $VAR1 = 'pt';
    $VAR2 = '0.0299573389196567';
    $VAR3 = 'tr';
    $VAR4 = '0.0152319153730931';
    $VAR5 = 'da';
    $VAR6 = '0.0359140188331814';
    ..../...


    But, I want an output like this one :

    $VAR1 = {
    'pt' => '0.0299573389196567',
    'tr' => '0.0152319153730931',
    'es' => '0.0403864688211945',
    'da' => '0.0359140188331814',
    };

    What's wrong ?
    Newsgroups, Feb 24, 2008
    #2
    1. Advertising

  3. Tad J McClellan

    Newsgroups Guest


    > Pass Dumper() a reference rather than a list of keys and values:
    > print Dumper \%languages;


    Yes, it's works in my example, then it doesn't works when I try to send
    the datas to a distant server using soap::lite
    Newsgroups, Feb 25, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Red Orchid
    Replies:
    3
    Views:
    1,024
  2. Pieter Claassen
    Replies:
    1
    Views:
    1,092
    CBFalconer
    Aug 4, 2004
  3. Bo Peng
    Replies:
    4
    Views:
    779
  4. rp
    Replies:
    1
    Views:
    491
    red floyd
    Nov 10, 2011
  5. Srijayanth Sridhar
    Replies:
    19
    Views:
    594
    David A. Black
    Jul 2, 2008
Loading...

Share This Page