Perl Language Dumping array list


Example

my @data_array = (123, 456, 789, 'poi', 'uyt', "rew", "qas");
print Dumper @data_array;

Using Data::Dumper gives an easy access to fetch list values. The Dumper returns the list values serialized in a way that looks like Perl code.

Output:

$VAR1 = 123;
$VAR2 = 456;
$VAR3 = 789;
$VAR4 = 'poi';
$VAR5 = 'uyt';
$VAR6 = 'rew';
$VAR7 = 'qas';

As suggested by user @dgw When dumping arrays or hashes it is better to use an array reference or a hash reference, those will be shown better fitting to the input.

$ref_data = [23,45,67,'mnb','vcx'];
print Dumper $ref_data;

Output:

$VAR1 = [
          23,
          45,
          67,
          'mnb',
          'vcx'
        ];

You can also reference the array when printing.

my @data_array = (23,45,67,'mnb','vcx');
print Dumper \@data_array;

Output:

$VAR1 = [
          23,
          45,
          67,
          'mnb',
          'vcx'
        ];