0
#!/usr/bin/perl   
use strict;
use warnings;
my @array = (
    [1,2,3,4],
    [5,6,7,8]
);
my @second_row = @{ $array[1] };
print "Second row: [@second_row]\n";

getting output as : Second row: [5 6 7 8]
but i need it as : Second row: [5, 6, 7, 8]

1 Answer 1

4

What you want is the join function. Try something like:

print "Second row: [", join(', ', @second_row), "]\n";
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that works perfectly.I tried using join but was missing comma that you placed after and before double quotes !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.