You already have multiple answers to your question, but I would like to add another minor one here that might help to add something.
To view data structures in Perl you can use Data::Dumper
. To print a string you can use say
, which adds a newline character "\n"
after every call instead of adding it explicitly.
I usually use \s
which matches a whitespace character. If you add +
it matches one or more whitespace characters. You can read more about it here perlre
.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use feature 'say';
my $line = "file1.gz file2.gz file3.gz";
my @abc = split /\s+/, $line;
print Dumper \@abc;
say for @abc;