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

Dear Monks,

I am very new to perl.Need help with understanding some stuff..

I have having 3 loads. suppose a,b,c..

These loads get assigned in a variable $load turn by turn as they are in a loop.I am having departments of these three loads stored in another variable $dept..

I am trying to assign a value of a variable $loadrel for each $load to its corresponding $dept..

I am using this.

 $loadrel{$load} .="$dept";.

I am getting null as output.$loadrel is not getting set to any value..

Can you please guide me please..

Thanks in Advance.

Replies are listed 'Best First'.
Re: Need Help:Trying to assign Conditional Value to a variable
by Anonymous Monk on Feb 17, 2012 at 00:23 UTC

    I am using this.  $loadrel{$load} .="$dept"; I am getting null as output. $loadrel is not getting set to any value..

    Sorry, but that is inadequate. In your code snippet $load and $dept are never defined, so of course they are undef.

    Instead of describing how you understand $dept and $load and %loadrel get defined , you need to show code that demonstrates that ( How do I post a question effectively?, Short, Self Contained, Correct (Compilable), Example)

    For example

    #!/usr/bin/perl -- use strict; use warnings; use Data::Dumper; my %loadrel; for my $load ( qw/ a b c /){ for my $dept ( qw/ 1 2 3 / ){ $loadrel{$load} .= " $dept "; } } print Dumper( \%loadrel ); __END__ $VAR1 = { 'c' => ' 1 2 3 ', 'a' => ' 1 2 3 ', 'b' => ' 1 2 3 ' };
Re: Need Help:Trying to assign Conditional Value to a variable
by TJPride (Pilgrim) on Feb 17, 2012 at 10:02 UTC
    Supply sample input data and a text representation of what you want the output data structured like. I'm afraid we're not psychics.