X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FSlob.pm;h=8298becd0e964bb8e1e3508ff9f811793cc67cdd;hb=0e15b49616308e77f3f6ede65711ea70a876af47;hp=b1eb4f8a7bae668dff5365a1580834b89a35b119;hpb=d3779104ff18ac718524de579f1d5247c30cc48a;p=slob.git diff --git a/lib/Slob.pm b/lib/Slob.pm index b1eb4f8..8298bec 100644 --- a/lib/Slob.pm +++ b/lib/Slob.pm @@ -197,6 +197,15 @@ sub get_entry_of_storage_bin { substr $start_of_data, 4, $length; } +sub seek_and_read_ref_and_data { + my ($self, $index) = @_; + my $ref = $self->seek_and_read_ref($index); + my $bin = $self->seek_and_read_storage_bin($ref->{bin_index}); + my $data = $self->get_entry_of_storage_bin($bin, $ref->{item_index}); + $ref->{data} = $data; + $ref +} + 1; __END__ @@ -225,6 +234,11 @@ Slob - Read .slob dictionaries (as used by Aard 2) say "Value at position $second_ref->{item_index} is ", $slob->get_entry_of_storage_bin($bin, $second_ref->{item_index}); + # instead of the above, we can do + my $second_ref_and_data = $slob->seek_and_read_ref_and_data(4); + say "Entry is for $second_ref_and_data->{key}"; + say "Value is $second_ref_and_data->{data}"; + =head1 DESCRIPTION No documentation yet, see SYNOPSIS.