in reply to Parse a pipe-delimited list

If you're just translating shell scripts, you shouldn't have any need to escape the pipes in the data. In that case plum's use of split should work fine and it will keep the code local and minimize dependencies, making it easier to wrap your mind around while you're learning perl.

The other question is where you want to put the data that you parse. You can put the values in individual variables, in a %config hash, or you can put them in the %ENV hash, which is a copy of the shell's environment. Below are examples of each. I included the use of a hash slice. It's beyond what you should already understand as a newbie, but it's not that far of a stretch, if you're in the mood for it, and it has a certain conciceness.

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;