deduct string values from hash

B

Bart Van der Donck

Hello,

I'm using mthe odule WebService::StreetMapLink to return a visual map
of address coordinates.

#!/usr/bin/perl
use strict;
use warnings;
use WebService::StreetMapLink;

my $map =
WebService::StreetMapLink->new
( country => 'switzerland',
address => 'rue de Paquis 25',
city => 'Geneva',
state => 'Geneve',
postal_code => '1201',
);
my $uri = $map->uri;
print "the url is ".$uri;

The perl code comes straight out of:
http://search.cpan.org/~drolsky/Web...0.09/lib/WebService/StreetMapLink/Multimap.pm

Info about the actual module:
http://search.cpan.org/~drolsky/WebService-StreetMapLink-0.09/lib/WebService/StreetMapLink.pm

Result of this script is:

the url is http://www.multimap.com/map/
places.cgi?HASH(0x82047a8)

The problem is that there seems no way to fetch the 'real' hashed
values out of $uri after the question mark.

The weird thing is that $uri is an ordinary var, but the HASH(XXX) is
always present after the question mark. I tried all tricks I can think
of (walk trhough hashes, %uri, %map, alternative declarations...). But
there seems no way to 'un-hash' it into something like:

http://www.multimap.com/map/places.cgi?street=rue
%20de%20Paquis25&city=Geneve&country=switzerland

(I suppose the actual url should be in a kind of format like this)

First part (before the question mark) looks like a common URI value.
The second part (after the question mark) looks to me like wrongly
formatted output that has something to do with a hash. Maybe $uri is a
half-hash :)

Thanks,
 
J

J. Gleixner

Bart said:
Hello,

I'm using mthe odule WebService::StreetMapLink to return a visual map
of address coordinates.

#!/usr/bin/perl
use strict;
use warnings;
use WebService::StreetMapLink;

my $map =
WebService::StreetMapLink->new
( country => 'switzerland',
address => 'rue de Paquis 25',
city => 'Geneva',
state => 'Geneve',
postal_code => '1201',
);
my $uri = $map->uri;
print "the url is ".$uri;

The perl code comes straight out of:
http://search.cpan.org/~drolsky/Web...0.09/lib/WebService/StreetMapLink/Multimap.pm

Info about the actual module:
http://search.cpan.org/~drolsky/WebService-StreetMapLink-0.09/lib/WebService/StreetMapLink.pm

Result of this script is:

the url is http://www.multimap.com/map/
places.cgi?HASH(0x82047a8)

The problem is that there seems no way to fetch the 'real' hashed
values out of $uri after the question mark.
[...]

You could try Data::Dumper, however I installed the package, also needed
to install Geography::States, cut & pasted your code, ran it and it
produced, the following (all on a single line):

the url is
http://www.multimap.com/map/places....H&addr3=Geneva&overviewmap=&pc=1201&advanced=

which seems apropos.

Seems like something isn't installed correctly. I'd suggest
re-installing it, and Geography::States. If that fails, then walk
through the uri method with the debugger to see what's failing. The
current version on CPAN seems to work as expected, for me.
 
B

Bart Van der Donck

J. Gleixner said:
You could try Data::Dumper, however I installed the package,
also needed to install Geography::States

I have Geography::States, that should be no problem.

Data::Dumper says for 'print Dumper($uri);':

$VAR1 = 'http://www.multimap.com/map/places.cgi?
HASH(0x823fb84)=';

and for 'print Dumper($map);':

$VAR1 = bless( { 'query' => { 'addr2' => 'rue de
Paquis 25', 'client' => 'public', 'db' => 'CH',
'addr3' => 'Geneva', 'overviewmap' => '', 'pc' =>
'1201', 'advanced' => '' }, 'path' => '/map/places.cgi',
'host' => 'www.multimap.com' },
'WebService::StreetMapLink::Multimap' );

[...]
If that fails, then walk through the uri method with the
debugger to see what's failing. The current version on
CPAN seems to work as expected, for me.

When calling the script from the command line, it gives an error:

%perl -wle "use WebService::StreetMapLink; my $map
= WebService::StreetMapLink->new ( country => 'switzerland',
address => 'rue de Paquis', city => 'Geneva', state
=> 'Geneve', postal_code => '1201', subclass => 'Multimap'
);my $uri = $map->uri(); print 'the url is '.$uri;"
map: Undefined variable.
%

The code is the same - as CGI the program continues and doesn't
complain, even with

use CGI::Carp qw(fatalsToBrowser);

P.S. The previous mail had a small error, the program didn't output

the url is http://www.multimap.com/map/
places.cgi?HASH(0x82047a8)

but

the url is http://www.multimap.com/map/
places.cgi?HASH(0x82047a8)=

(with '='-sign at the end)

Thanks,
 
J

J. Gleixner

Bart said:
When calling the script from the command line, it gives an error:

Why do that? Just edit a file and run it. That way you can easily make
changes.
The code is the same - as CGI the program continues and doesn't
complain, even with

Ahhhh a hidden CGI question? :) There must be something else going on.
What does the following print, for your CGI?


use CGI qw:)standard);
use strict;
use warnings;
use WebService::StreetMapLink;

print header;

my $map = WebService::StreetMapLink->new
( country => 'switzerland',
address => 'rue de Paquis 25',
city => 'Geneva',
state => 'Geneve',
postal_code => '1201',
);
my $uri = $map->uri;
print "the url is ".$uri;
# Note, no need to use concat '.' there..
# print "the url is $uri"; # will work
# print "the url is ", $uri; # will also work
 
B

Bart Van der Donck

J. Gleixner wrote:

[...]
There must be something else going on.
What does the following print, for your CGI?

[...]

I did that test but it was the same result with the 'HASH'-stuff after
the question mark.

I mailed the author of WebService::StreetMapLink. It appears that my
URI.pm was version 1.23 and it had to be at least 1.28. After that
update, everything worked fine. The reason why it worked for you, is
probably because you're having URI.pm 1.28+ already.
 
A

Anno Siegel

[...]
When calling the script from the command line, it gives an error:

%perl -wle "use WebService::StreetMapLink; my $map
= WebService::StreetMapLink->new ( country => 'switzerland',
address => 'rue de Paquis', city => 'Geneva', state
=> 'Geneve', postal_code => '1201', subclass => 'Multimap'
);my $uri = $map->uri(); print 'the url is '.$uri;"
map: Undefined variable.

That is a shell error, not a Perl error. Use single quotes to quote
the Perl code for -e.

Anno
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top