Re: How to Tie Existing File to Hash

Discussion in 'Perl' started by SpecialK, Feb 20, 2004.

  1. SpecialK

    SpecialK Guest

    I have a 150k line file that I am trying to convert to a hash.
    Each line has a number, e.g. first line has 50000000, last line has 50149999
    The message I get is basically, I am running of shared memory.
    Here is the code:


    use IPC::Shareable;
    %ShmOptions = ('create' =>1, 'exclusive' =>0, 'mode' =>0666, 'destroy'
    =>0);
    eval {tie(%hashofGuids, 'IPC::Shareable', 'hashguid', %ShmOptions}) };
    my guidfile ='/home/gregk/www/guid_excluded.dat';

    open(GUIDS, guidfile) or die "couldn't open file: $!";
    (tied %hashofGuids)->shlock;
    while(<GUIDS>)
    {
    chomp($eachline = $_;
    $hashofGuids{$eachline} = 1;
    }
    (tied %hashofGuids)->shunlock;
    ## At this point I get the running out of shared memory message ###

    I tried used size=>xxx in the %ShmOptions statement but I get an invalid
    size error message.

    I am open to any suggestions,

    thanx,
    greg



    "WC -Sx- Jones" <> wrote in
    message news:...
    > SpecialK wrote:
    > > Does anyone know how to tie a large existing file(each record is a 8byte
    > > number) to a Hash using IPC::Shareable?
    > > Any Code fragments would be most helpful.

    >
    > Why doesnt:
    >
    > http://search.cpan.org/~bsugars/IPC-Shareable-0.60/lib/IPC/Shareable.pm
    >
    > Address your question?
    > -Sx-
    >
    > PS - See also:
    > http://london.pm.org/pipermail/london.pm/Week-of-Mon-20030818/020948.html
     
    SpecialK, Feb 20, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SpecialK

    Tie a file to a hash

    SpecialK, Feb 19, 2004, in forum: Perl
    Replies:
    1
    Views:
    474
    Ben Morrow
    Feb 19, 2004
  2. SpecialK

    Tie a large file to a Hash

    SpecialK, Feb 19, 2004, in forum: Perl
    Replies:
    0
    Views:
    458
    SpecialK
    Feb 19, 2004
  3. rp
    Replies:
    1
    Views:
    555
    red floyd
    Nov 10, 2011
  4. botfood

    tie() with DB_File not tie()ing ?

    botfood, Apr 24, 2006, in forum: Perl Misc
    Replies:
    23
    Views:
    464
    botfood
    Apr 26, 2006
  5. Eric

    Dumping Perl tie hash file

    Eric, Mar 9, 2007, in forum: Perl Misc
    Replies:
    6
    Views:
    176
    DJ Stunks
    Mar 10, 2007
Loading...

Share This Page