my $line = \"file1.gz file2.gz file3.gz\";
my @abc = split(\'\', $line);
print \"@abc\\n\";
Expected output:
file1.gz
file2.gz
file3.gz
Having $line
as it is now, you can simply split the string based on at least one whitespace separator
my @answer = split(' ', $line); # creates an @answer array
then
print("@answer\n"); # print array on one line
or
print("$_\n") for (@answer); # print each element on one line
I prefer using ()
for split
, print
and for
.