> -----Original Message-----
> From: Bobby [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 22, 2008 12:33
> To: Rob Dixon; beginners@perl.org
> Cc: Bobby
> Subject: Re: hash
> 
> Rob,
> 
> Yes the pids are unique. 
> 
> I've tried the comparison below but didn't worked, so what do 
> you think is wrong with it?
> 
> if ($pidsizes{$pid}{US} = $pidsizes{$pid}{EU}){
>         print "$pidsizes{US}{$us}";
> 
        = should be == otherwise you are doing an assignment and test.
Are you using use strict and warnings? If you were, you would have
received a heads up that something was wrong.

        Should always use, though you can turn off for spots in the
code, it should be a regular practice and cuts down on a lot of time and
effort.

Wags ;)

> Rob Dixon <[EMAIL PROTECTED]> wrote: Bobby wrote:
> > 
> > I have a flat file that contains a pid, us_size and 
> euro_size. I want to
> > create read in the file and create one hash for the us_size 
> (%US) and the
> > other for the euro_size (%EURO). Then i want to do a print 
> statement if the
> > pid value in the us_size hash is equal to pid value in the euro_size
> > hash...maybe IF ($US{$pid} = $EURO{$pid}) {print statement...}.
> > 
> > The part where i'm stuck on is how to assign the data into 
> a hash and do the
> > comparison, could one of you help me with the Perl's syntax 
> or point in the
> > right direction?
> > 
> > pid|us_size|euro_size
> > 1|10|34
> > 2|11|35
> > 3|12|37
> > 4|13|
> 
> Another question that skips the /problem/! Are you aware that 
> you can store
> multiple values - even another hash or array - as the value 
> of a hash element?
> 
> At a guess, you need to be able to access a US and EU size 
> for a given PID, and
> I would write a loop like this
> 
>   my %pidsizes;
> 
>   while () {
>     chomp;
>     my ($pid, $us, $eu) = split /\|/;
>     $pidsizes{$pid}{US} = $us;
>     $pidsizes{$pid}{EU} = $eu;
>   }
> 
> Does that help? Are the PIDs in your file unique? Is the 
> missing Euro size for
> PID 4 a mistake or a special case?
> 
> Rob
> 
> 
>        
> 

**********************************************************************
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**********************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to