Array/hash question.

They have: 62 posts

Joined: May 2000

Let's say I open a file. Can I apply the file array to a hash? So that they file info would in key/value pairs? If so, how do I do it?

They have: 568 posts

Joined: Nov 1999

You can't open a regular file as a hash. But you can go through each line of the file then assign it to a has.

Can you be more specific?

He has: 32 posts

Joined: Mar 1999

# read the file
@lines = ;

# parse data into the hash named 'values'

foreach $line (@lines) {

($key,$value) = split(/\|/,$line);
$values{$key} = $value;

}

later Smiling

http://www.patrickbaer.com
Professional Photo Retouching Services

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.