in reply to Using formats for 2-columnprinting
Note the use of the repeating format line to execute that value as long as data is available, then stop when it's not.{ my $value; my $hash_ref; my $done; sub get_key { unless ($done) { (my $key, $value) = each %$hash_ref or # yes, $value is out of s +cope $done = 1; } defined $key ? $key : ""; } sub get_value { defined $value ? $value : ""; } sub set_hash { $hash_ref = shift; keys %$hash_ref; # reset each() $done = 0; } } set_hash(\%hash_you_want_to_scan); write STDOUT; format STDOUT = @>>>>> @### @>>>>> @### ~~ get_key(), get_value(), get_key(), get_value() .
-- Randal L. Schwartz, Perl hacker
Too early in the morning for this. {grin}sub get_key { my $key; unless ($done) { ($key, $value) = each %$hash_ref or # yes, $value is out of scop +e $done = 1; } defined $key ? $key : ""; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jcwren) Re: (2) Using formats for 2-columnprinting
by jcwren (Prior) on Oct 03, 2000 at 18:14 UTC | |
by merlyn (Sage) on Oct 03, 2000 at 18:16 UTC | |
by merlyn (Sage) on Oct 03, 2000 at 18:20 UTC |