How to get an unique element from two arrays in Perl -


i have tried list of unique elements in first array. (aka: elements in first array not in second array.) script returns number of unique elements not info in each element.

as newbie perl, know there many nuances language. have not seen how getting number instead of list of elements. research have seen how number of unique elements , apparently, have discovered way.

any appreciated. below code.

#!/usr/bin/perl  use strict; use warnings; use v5.10;  use xml:simple; use lwp::simple; use list::compare;  @upd = system ("perl test.pl | grep '*.x86_64.rpm'"); @inst = system ("rpm -qa");  @inst = join( '.rpm', @inst);  $ls = list::compare->new( {lists=> [\@upd, \@inst]} ); @list = $ls->get_unique; @list = $ls->get_lonly;  "@list"; 

@upd contains 1 element, exit status of shell executed perl test.pl | grep '*.x86_64.rpm'. similarly, @inst contains 1 element, exit status of rpm. perhaps trying capture output? use backticks.

my @upd  = `perl test.pl | grep '*.x86_64.rpm'`; chomp(@upd);  @inst = `rpm -qa`; chomp(@inst); 

also, following incorrect:

@inst = join( '.rpm', @inst); 

it should replaced following:

$_ .= '.rpm' @inst; 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -