Next | Lightweight Databases | 89 |
->seq provides generic sequential access to the keys
In the user-defined order
Note: C-style for loops coming up
To scan the keys forwards:
my $db = tied %hash; my ($k, $v, $fail); for ($fail = $db->seq($k, $v, R_FIRST) ; ! $fail ; $fail = $db->seq($k, $v, R_NEXT) ) { print "$k => $v\n"; }
Or backwards:
for ($fail = $db->seq($k, $v, R_LAST); ! $fail; $fail = $db->seq($k, $v, R_PREV) ) { print "$k => $v\n"; }
Or just the keys between $a and $b:
$k = $a; for ($fail = $db->seq($k, $v, R_CURSOR); ! $fail && $k le $b; $fail = $db->seq($k, $v, R_NEXT) ) { print "$k => $v\n"; }
Next | Copyright © 2003 M. J. Dominus |