Begin forwarded message:

From: drieux <[EMAIL PROTECTED]>
Date: December 4, 2003 8:11:46 PM PST
To: "B. Fongo" <[EMAIL PROTECTED]>
Subject: Re: Pattern matching


On Dec 4, 2003, at 7:09 PM, B. Fongo wrote:



sub select_newer { my (@remote_packages, @installed_packages); (@remote_packages, @installed_packages) = @_; foreach (@installed_packages){ my $i = grep {$_} @remote_packages && ; }

I'll appreciate any help

that's not going to work the way you would like since perl does not take in two arrays like that.

What you will need is a bit of indirection
by dealing with references.

sub select_newer {
    my ($remote_packages, $installed_packages) = @_;
    foreach (@$installed_packages){
         my $i = grep {$_} @$remote_packages && ;
}

You can now pass in the two arrays as

my $need_list = select_newer([EMAIL PROTECTED], [EMAIL PROTECTED]);

then iterate over it in the class form of

        foreach my $pkg ( @$need_list)
        {
                # do the stuf with it.
        }

That being said, you might want to think about a
strategy of something like

         my @remote_packages = qw(perl-5.8.0-88.3.i386.rpm
        samba-2.2.7-5.7.0.i386.rpm bob-5.3.2.4.1.rpm);
        
         my @installed_packages = qw(perl-5.8.0-80.3.i386.rpm
         samba-2.2.7-5.8.0.i386.rpm  bob-5.3.2.4.1.rpm);
        
        
        my $need_list = check_lists([EMAIL PROTECTED] , [EMAIL PROTECTED]);
        
        foreach my $pkg (@$need_list)
        {
                print "need $pkg\n";
        }
        
        #------------------------
        #
        sub check_lists
        {
                my ($src, $dst) = @_;
                
                #Making a quick pick hash
                my %src_hash = map { $_ => 1 } @$src;
                
                my @need_list;
                
                foreach my $key ( @$dst )
                {
                        push(@need_list, $key)
                                unless(exists($src_hash{$key}));
                }
                
                [EMAIL PROTECTED];
                
        } # end of check_lists

Or are you expecting that you MIGHT get into the case where
you have downloaded and installed 'a newer version' say
the case where you installed

bob-5.4.pm

and do not want to 'back rev' yourself??

ciao
drieux

---




ciao
drieux

---


-- 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