LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 08-09-2006, 07:21 PM   #1
PB0711
Member
 
Registered: Aug 2004
Location: London, UK
Distribution: Ubuntu 10.10, ubuntu 11.04, suse 9.2, OSX
Posts: 259

Rep: Reputation: 30
Perl List::Compare printing


Hey all,

So I would have posted on the perl news thing but I just had a very snobby reply on another questiion I had. Anyway, I am trying to get List::Compare to work. It's working, I think but I just cannot seem to dereference it. This is what I have, it's only a test script.
Code:
#!usr/bin/perl -w
use strict;
use List::Compare;

my @Llist = qw(abel abel baker camera delta edward fargo golfer);
my @Rlist = qw(baker camera delta delta edward fargo golfer hilton);

my $lc = List::Compare->new(\@Llist, \@Rlist);

print "$lc\n";

foreach my $k (keys %$lc) {
        print "$k: " . $lc->{$k} . "\n";
}
I get the keys but then I get the array reference. Has it made an HoA or something?
there is a line
Code:
 $lc->print_subset_chart;
but it's not really telling me what the difference is between the two arrays.
 
Old 08-10-2006, 01:06 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,389

Rep: Reputation: 97
i guess u better use the methods supplied by the module to print out results...

# Get those items which appear at least once in both lists (their intersection).

@intersection = $lc->get_intersection;

# Get those items which appear at least once in either list (their union).

@union = $lc->get_union;

# Get those items which appear (at least once) only in the first list.

@Lonly = $lc->get_unique;
@Lonly = $lc->get_Lonly; # alias

# Get those items which appear (at least once) only in the second list.

@Ronly = $lc->get_complement;
@Ronly = $lc->get_Ronly; # alias

# Get those items which appear at least once in either the first or the second list, but not both.

@LorRonly = $lc->get_symmetric_difference;
@LorRonly = $lc->get_symdiff; # alias
@LorRonly = $lc->get_LorRonly; # alias

# Make a bag of all those items in both lists. The bag differs from the union of the two lists in that it holds as many copies of individual elements as appear in the original lists.

@bag = $lc->get_bag;
 
Old 08-10-2006, 12:59 PM   #3
PB0711
Member
 
Registered: Aug 2004
Location: London, UK
Distribution: Ubuntu 10.10, ubuntu 11.04, suse 9.2, OSX
Posts: 259

Original Poster
Rep: Reputation: 30
Oh sorry I was in a rush and just searched for print

Thx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to list all installed Perl modules SharpyWarpy Linux - General 8 12-12-2011 04:48 AM
type of list element in Perl ? thelonius Programming 2 06-20-2006 08:49 AM
how to list/install perl modules lsimon4180 Linux - Software 1 10-02-2004 12:57 PM
Perl program to list listening ports doza Programming 1 07-29-2004 01:57 PM
perl printing pantera Programming 1 06-02-2004 02:07 PM


All times are GMT -5. The time now is 05:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration