in reply to Array / String

Use join, and stick the first and last delimiter to the ends manually.

Something like:

my $result = '#(#string#' . join('#;#string#', @array) . '#)#;

Or a bit prettier:

my $result = sprintf '#(#string#%s#)#',join('#;#string#', @array);

Replies are listed 'Best First'.
Re^2: Array / String
by mightycare (Initiate) on Oct 12, 2011 at 10:36 UTC
    Thanks moritz, in the mean time i figured out this:
    my @dnsSuffixList = qw ( 10.0.0.1 10.0.02 10.0.03 10.0.04 ); my $str = join ('#;#string#', @dnsSuffixList); $str =~ s/$str/#{#string#$str#}#/; # print $str;
    What do you think is faster? sprintf or sed?