janasec has asked for the wisdom of the Perl Monks concerning the following question:

I have an array I need some format help,I need to keep this in variable

the code is like this

print "@array_wwpn\n"; chomp @array_wwpn; my $somewwpnNames = join('";', @array_wwpn); print "$somewwpnNames";
@array_wwpn when printed it contains before chomp and join is applied +looks like 10000090fa2edda0 10000090fa2edd9f 10000000c9cdcc6c 10000000c9cdcc6d I need the $somewwpnNames to contain like this $somewwpnNames="10000090fa2edda0";"10000090fa2edd9f";"10000000c9cdcc6 +c";10000000c9cdcc6d";

Replies are listed 'Best First'.
Re: array format question
by pme (Monsignor) on Jul 26, 2015 at 10:06 UTC
    my $somewwpnNames = '"' . join('";"', @array_wwpn) . '";'; print "$somewwpnNames\n";
Re: array format question
by Corion (Patriarch) on Jul 26, 2015 at 09:17 UTC

    Maybe you want to use a proper CSV writer like Text::CSV_XS?

    Also, what is the output you get with your current program, and how is the output you currently get different from what you want? Maybe you are joining the strings with the wrong stuff in the middle?

Re: array format question
by kroach (Pilgrim) on Jul 26, 2015 at 12:19 UTC
    local $"=q(";"); my $somewwpnNames = qq("@array_wwpn";);
Re: array format question
by Laurent_R (Canon) on Jul 26, 2015 at 13:04 UTC
    print join ";", map {'"' . $_ . '"'} @array_wwpn;