Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Looking for the error in this code!

by Sombrerero_loco (Beadle)
on Jan 12, 2009 at 12:46 UTC ( [id://735658]=perlquestion: print w/replies, xml ) Need Help??

Sombrerero_loco has asked for the wisdom of the Perl Monks concerning the following question:

Hi seekers. Im really annoyed, i really dont where its the bug in this lines:

foreach $asignador_final (keys (%final)) {
	foreach $asignador_index (keys(%index)) {
		=> if (%index{$asignador_index}{"servicio"} eq "portal" && $asignador_final eq $asignador_index) {
			$index{$asignador_index}{"estado"} = $final{$asignador_final}{"estado_max"}
		}
    }
}
The debbuger told me i have a syntax error after the arrow Something weird inside in invisible mode.. :)

Replies are listed 'Best First'.
Re: Looking for the error in this code!
by moritz (Cardinal) on Jan 12, 2009 at 12:49 UTC
    When you access a hash item, the % becomes a $. %index is accessed as $index{foo}. See perlintro and perldata.

    Oh, and I hope you put the => only in for illustration, it would make no sense in real code.

      ha ha ha yes, => its only for see it better... i think i dont have a very good to do perl, i did't saw it...my god :=) Thanks! should i go sleep?
Re: Looking for the error in this code!
by jwkrahn (Abbot) on Jan 12, 2009 at 13:22 UTC

    Also, you don't need two loops there, you can do it in one loop:

    for my $asignador_index ( keys %index ) { if ( $index{ $asignador_index }{ servicio } eq 'portal' && exists +$final{ $asignador_index } ) { $index{ $asignador_index }{ estado } = $final{ $asignador_inde +x }{ estado_max } } }
      thanks, such a better way to do that!....less cpu cycles wasted :) thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://735658]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found