use strict; use warnings; my $str = 'bar|development|/usr/bar/db|/dbdump'; # put the values into individual variables; my ($db,$host,$dbdir,$dumpdir); ($db,$host,$dbdir,$dumpdir) = split '\|',$str; # put the values into a hash my %conf; ( $conf{'DB'}, $conf{'HOST'}, $conf{'DBDIR'}, $conf{'DUMPDIR'} ) = split '\|',$str; # print out the hash with for (keys %conf) { print "$_ => $conf{$_}\n"; } # Use a hash slice. The %conf hash is given # a list of keys. The "=" assigns to each of them in turn @conf{('DB','HOST','DBDIR','DUMPDIR)} = split '\|',$str; # put the values into the %ENV hash, where the other # environment variables are @ENV{qw(DB HOST DBDIR DUMPDIR)} = split '\|',$str;