in reply to Re: Re: Re: Making a hash of making a hash of an array
in thread Making a hash of making a hash of an array

Once again, I appreciate your help.

I only put the "culprit" line in because what I had before was only giving the last line read out and I attempted to 'reformat' the hash as per the example on the html-template tutorial page. How wrong I was...!

Your advice has made me realise that instead of the while ($count < 10){ #loop } I had used:

if ($count < 10){ $member{$timestamp} = [$current_time, $funds, $action, $current_fu +nds]; $count += 1; }
all would have worked okay and I would have unwittingly missed out on a great deal of good advice...:)

Thanks once again.

Replies are listed 'Best First'.
(jeffa) 5Re: Making a hash of making a hash of an array
by jeffa (Bishop) on Jun 04, 2003 at 14:01 UTC
    Consider this instead:
    my @array = (1..20); my $i = 0; for (@array) { print "$_\n"; last if ++$i >= 10; }
    This is one of the jobs that last was built for. Now consider this one:
    my @array = (1..20); print "$_\n" for @array[0..9];
    That's called an array slice, another tool that seperates Perl from C. Play around with these two snippets. You'll learn something. ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)