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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -