in reply to read-only error

The Read only error accurred on line 868 which is :
my %uniq;
could someone explain to me what the last 3 line is doing line by line?

Thanks,
Paul

Replies are listed 'Best First'.
Re^2: read-only error
by grep (Monsignor) on Aug 24, 2006 at 18:31 UTC
    The Read only error accurred on line 868 which is : my %uniq; could someone explain to me what the last 3 line is doing line by line?

    Yes but you have more problems as I stated above;

    my %uniq; # create a hash called %uniq undef @uniq{@dist_list}; # takes the array @dist_list as keys to create in %uniq # each with the value undef. # Since you can only have 1 unique key in a hash this # has the effect of filtering out repeats #ex. # # %uniq = { # '1 2 3' => undef, # '4 5 6' => undef, # '5 6 7' => undef # }; @dist_list = keys %uniq; # this pulls the keys from %uniq and assings them to @dist_list
    So this code is not a problem - you need to fix the other problems first.


    grep
    Mynd you, mønk bites Kan be pretti nasti...
Re^2: read-only error
by ikegami (Patriarch) on Aug 24, 2006 at 18:32 UTC

    Sometimes, the line number in error messages are off by a bit. I think that's the case here.

    undef @uniq{@dist_list};
    is equivalent or similar to
    $uniq{$_} = undef for @dist_list;

    Together, the three lines remove duplicate items in @dist_list, assuming @dist_list only contains strings. (Anything in @dist_list which isn't a string is first converted to a string.) The order of the items in @dist_list is not guaranteed to remain unchanged.

    By the way, it's <code>..</code> (or <c>..</c>), not <code>..<code/>.