Click here to get back home

hash

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
hash Newsgroups 02-24-2008
---> Re: hash Tad J McClellan02-24-2008
  ---> Re: hash Newsgroups02-25-2008
    `--> Re: hash RedGrittyBrick02-25-2008
Posted by Newsgroups on February 24, 2008, 9:43 am
Please log in for more thread options
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 ?


Posted by Tad J McClellan on February 24, 2008, 9:40 am
Please log in for more thread options
> 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.noitatibaher0cmdat/"

Posted by Newsgroups on February 25, 2008, 1:34 pm
Please log in for more thread options

> 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



Posted by RedGrittyBrick on February 25, 2008, 2:25 pm
Please log in for more thread options
Newsgroups wrote:
>> 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
>
>

SOAP::Lite has a debug option which I have found to be useful.

You can also output the received XML using "->outputxml(1)";

By using Data::Dumper at both ends you should be able to work out how to
handle the data consistently.

I found that experimenting with SOAP::Data was useful in understanding
SOAP::Lite a little better.

Similar ThreadsPosted
Perl hash and rehash seeds; deterministic hash ordering January 19, 2007, 5:01 pm
copying values from a hash into CGI.pm via tied hash reference December 27, 2004, 7:02 am
Module for getting values from "flattened" hash or "recursed" hash...? March 8, 2005, 7:05 pm
Combining multiple hash references into one hash reference September 1, 2005, 1:47 pm
Adding values to anon hash of hash while looping... September 2, 2005, 7:42 am
Sort by hash vaule, an array of hash references October 6, 2005, 12:52 pm
Searching an example for a defined hash value of a nonexisting hash key July 20, 2004, 5:47 pm
Perh Hash of Hash of Array structure March 29, 2007, 2:52 pm
how access to hash which contains hash and sclar var? December 12, 2004, 12:09 am
Accessing Hash of hash of arrays February 14, 2005, 9:39 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap