in reply to Array values into hash

The other way is to use eval:
use Data::Dumper; use strict; undef $/; open(FILE, "<", "test.txt"); $_ = <FILE>; close(FILE); s/\|\n/\,/g;#may need to modify according to newline on your platform, + this is fine with win32 s/\|/=>/g; my $hash ; eval("\$hash = {$_}"); print Dumper($hash);

Replies are listed 'Best First'.
Re: Re: Array values into hash
by demerphq (Chancellor) on Feb 09, 2003 at 15:09 UTC
    I feel obliged to point out that this is an insane way to do this. The security implications, the fact that that you have undefed $/ without localization, the fact that you are potentially reading in a huge file to memory all make this a very bad solution.

    Sorry.

    --- demerphq
    my friends call me, usually because I'm late....