For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2005 > weird return









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author weird return
Brent Clark

2005-08-03, 3:59 am

Hi list

I have my code as so:

for my $roomCode ( keys %{ $ref_hash->{$fileName} } ){
my $roomName = $ref_hash->{$fileName}{$roomCode};

if( $pCode eq 'p110'){
if ($p110rm01 eq $roomName ){
$finalHash{$fileName}[0] = $roomName;


my Data::Dumper return as so:

'Grac01' => [
${\$VAR1->{'Mabu01'}[0]}, #This is not correct
'Suite',
'Penthouse'
],

Would anyone know why I get this back

I tried print just after I have
my $roomName = $ref_hash->{$fileName}{$roomCode};

and the print is fine.

its just when I add the name to the hash or arrays.

If anyone could point out where im going wrong, I would greatfully
appreciate your help.

Kind Regards
Brent Clark

Brent Clark

2005-08-03, 10:00 pm

Brent Clark wrote:
> Hi list
>
> I have my code as so:
>
> for my $roomCode ( keys %{ $ref_hash->{$fileName} } ){
> my $roomName = $ref_hash->{$fileName}{$roomCode};
>
> if( $pCode eq 'p110'){
> if ($p110rm01 eq $roomName ){
> $finalHash{$fileName}[0] = $roomName;
>
>
> my Data::Dumper return as so:


Hi list

This is soo weird because I have it more then once:

$VAR1 = {
'Alph02' => [
'Chalet'
],
'Grac01' => [
${\$VAR1->{'Mabu01'}[0]},
'Suite',
'Penthouse'
],
'Elle01' => [
'Standard Room (no-seaview) (Rm6)',
${\$VAR1->{'Mabu01'}[0]},
${\$VAR1->{'Mabu01'}[0]},
'Ellerman Suite (Suite 7)',
'East Wing Suite (Suite 11)'
],
'Vine01' => [
${\$VAR1->{'Mabu01'}[0]},
${\$VAR1->{'Mabu01'}[0]},
'Mountain Facing Room',
'River Deluxe Suite',
'Courtyard Facing Suite',
'Mountain Facing Suite'
],
John Doe

2005-08-03, 10:00 pm

Brent Clark am Mittwoch, 3. August 2005 10.43:
> Hi list


Hi

> I have my code as so:
>
> for my $roomCode ( keys %{ $ref_hash->{$fileName} } ){
> my $roomName = $ref_hash->{$fileName}{$roomCode};
> if( $pCode eq 'p110'){
> if ($p110rm01 eq $roomName ){
> $finalHash{$fileName}[0] = $roomName;


Please post all relevant code, and data in $ref_hash.
Best to post a runnable example.

$pCode is not defined.
$p110rm01 is not defined.
$finalHash is not defined.

>
> my Data::Dumper return as so:
>
> 'Grac01' => [
> ${\$VAR1->{'Mabu01'}[0]}, #This is not correct


Could be a circular reference withing the data structure.

> 'Suite',
> 'Penthouse'
> ],
>
> Would anyone know why I get this back
>
> I tried print just after I have
> my $roomName = $ref_hash->{$fileName}{$roomCode};
>
> and the print is fine.
>
> its just when I add the name to the hash or arrays.
>
> If anyone could point out where im going wrong, I would greatfully
> appreciate your help.
>
> Kind Regards
> Brent Clark


Brent Clark

2005-08-03, 10:00 pm

Brent Clark wrote:[color=darkred]
> Brent Clark wrote:
>

K sorry for been a pain

I realised my mistake,

But whats the diffs with

$finalHash{$fileName}[0] = $roomName;

or

push @{ $finalHash{$fileName} } , $roomName;


--
Brent Clark
MSN: brentgclark@hotmail.com
WEB: http://www.eccotours.biz
eMail: bclark@eccotours.biz
Tel: +27 21 683 0069
Fax: +27 21 683 6137
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com