"Rose" <> wrote:
> Is it possible for me to use "foreach" to make the following codes in a
> better way? I don't want to create subroutine and call. Because I can't
> use @%arr this time (%arr1 not equal to %arr[1]).
Perhaps you have written something in some other thread that I haven't
read that if I had read would make the above make sense, but otherwise
the above doesn't make sense.
> Copying the %arr1,
> %arr2, ..., %arrn into a single large array is impractical, because
> %arr1, ...n is already very large each.
@arrn = \(%arr1, %arr2, %arr3, %arr4);
This just creates references to each hash. The data in the hashes is not
copied, it just has two paths to get to it, through the old name and
through the new reference. But it would better to just work with @arrn
from the start and never have %arr1 to start with.
>
> while (($loc, $sub) = each(%arr1)) {
> print "$loc\tSub\t$sub\t$notes[0]\t$start\t$end\n";
> }
>
> while (($loc, $sub) = each(%arr2)) {
> print "$loc\tSub\t$sub\t$notes[0]\t$start\t$end\n";
> }
foreach my $ref (@arrn) {
while (($loc, $sub) = each(%$ref)) {
print "$loc\tSub\t$sub\t$notes[0]\t$start\t$end\n";
}
};
Xho
--
--------------------
http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.