Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Using Set::Scalar with DF_File

Reply
Thread Tools

Using Set::Scalar with DF_File

 
 
Brian Halligan
Guest
Posts: n/a
 
      12-23-2003
I would like to use DB_File to store and retrive a large number of
sets in a hash. I have been using Set::Scalar to create and compare
the sets, but I have been having trouble storing these sets using
DB_File. When I try to retrive the set based on a hash key, I get a
string that looks like the print version of the set. I would like it
to return a new set that I could then compare to others. Do I have to
'take apart' the print version and then recreate the set, or is there
a simple way to avoid this overhead and save and retrive the set
structure directly? Thanks.


Brian Halligan
Bioinformatics Research Center
Medical College of Wisconsin
 
Reply With Quote
 
 
 
 
Jim Keenan
Guest
Posts: n/a
 
      12-24-2003

"Brian Halligan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I would like to use DB_File to store and retrive a large number of
> sets in a hash.


Since you didn't post any code, we have to guess as to how you went about
this. In particular, what are you using as the key to store each hash?


> I have been using Set::Scalar to create and compare
> the sets, but I have been having trouble storing these sets using
> DB_File. When I try to retrive the set based on a hash key, I get a
> string that looks like the print version of the set.


Cf. the discussion in the Set::Scalar POD about the "display format" for a
Set::Scalar object. I recall getting tripped up on this when I first
studied this module.

> I would like it
> to return a new set that I could then compare to others. Do I have to
> 'take apart' the print version and then recreate the set, or is there
> a simple way to avoid this overhead and save and retrive the set
> structure directly? Thanks.
>

Perhaps you could use the 'members' method:

use Set::Scalar;
use Data:umper;

my @a0 = qw(abel abel baker camera delta edward fargo golfer);
my @a1 = qw(baker camera delta delta edward fargo golfer hilton);
my @a2 = qw(fargo golfer hilton icon icon jerky);
my @a3 = qw(fargo golfer hilton icon icon);
my @a4 = qw(fargo fargo golfer hilton icon);

my $s0 = Set::Scalar->new(@a0);
my $s1 = Set::Scalar->new(@a1);
my $s2 = Set::Scalar->new(@a2);
my $s3 = Set::Scalar->new(@a3);
my $s4 = Set::Scalar->new(@a4);

my %HoA = (
s0 => [ $s0->members ],
s1 => [ $s1->members ],
s2 => [ $s2->members ],
s3 => [ $s3->members ],
s4 => [ $s4->members ],
);

print Dumper(\%Hoa); # I think this may give you what you want

For a simpler interface, you may wish to consider the List::Compare module
available from CPAN. Full disclosure: I wrote it. But I've never tried it
in conjunction with DB_File. HTH

Jim Keenan


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Link Button to redirect to another page by using data from =?Utf-8?B?R1REcml2ZXI=?= ASP .Net 1 02-16-2005 07:04 PM
Error page using the Application_Error void dosnt work when using DIV for a please wait message s_erez@hotmail.com ASP .Net 2 12-24-2004 12:11 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments