Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Making a hash of making a hash of an array

by kabel (Chaplain)
on Jun 04, 2003 at 04:58 UTC ( #262884=note: print w/replies, xml ) Need Help??

in reply to Making a hash of making a hash of an array

open (FILE, "$record") or die "can't open $record: $!"; my @record = reverse <FILE>; close FILE;

this is considered bad due to the fact that the file could eventually get large and fill up your memory. have a look at File::ReadBackwards.

%member = ( $timestamp => [$current_time, $funds, $action, $current_funds]);
this is 100% wrong, because %member contains afterwards exactly one element, the ten that got into before are lost. you want:

$member{$timestamp} = [$current_time, $funds, $action, $current_funds];
then, you really want to use strict; #damn ;) and to use CGI; or an equivalent module. see the tutorials for why.

update: i just realized that you don't chomp; your input lines. so, the last elem will have a line separator character at its end.


btw i hope formatting is correct ...

Replies are listed 'Best First'.
Re: Re: Making a hash of making a hash of an array
by jonnyfolk (Vicar) on Jun 04, 2003 at 05:24 UTC
    Thanks very much for your input, kabel, the File::ReadBackwards is especially interesting. I am actually using and strict but simply put in a snippet of my script which I thought the most relevant.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://262884]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2016-10-24 18:36 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.