Sonika Sachdeva wrote:
> Hi,

Hello,

> I have Hash of array. I want to compare the array values within the hash.
> How can it be done?
> 
> if ($eline =~ /$pattern/ ) {
>                 $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my
> $url=$4;

You shouldn't use the numerical variables if the pattern didn't match or their
values may not be what you expect.  Why capture $2 and $3 if you are not using
them?

my ( $uniq, $url ) = $eline =~ /(.*)"\w+\s.*\?(.*)"/;

>                 chomp($uniq);chomp($url);

Why did you think that using chomp() here would do anything useful?

>                 my @var= ( split("&",$url) );
>                 foreach my $k (@var) {
>                         @value = split("=",$k);
>                         if ( $value[0] eq "package_guid" ) { push
> @{$VAR{$uniq}},@value; }
>                         if ( $value[0] eq "deployment_id" ) { push
> @{$VAR{$uniq}},@value; }
>                         }
>                 foreach my $x (keys %VAR) {
>                         foreach my $y (keys %VAR) {
>                                 < Comparison code if 2 entries have same
> pacakge_guid >                        }
>                 }
>         }

If you only need to compare "package_guid" values maybe you need a Hash of
Hashes of Arrays instead.

for my $k ( split /&/, $url ) {
    my ( $key, @value ) = split /=/, $k;
        push @{ $VAR{ $uniq }{ $key } }, @value;
        }
    }

for my $x ( @{ $VAR{ $uniq }{ package_guid } } ) {
    # ???
    }



John
-- 
use Perl;
program
fulfillment

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


Reply via email to