To declare a string array in Perl, you can use array literal syntax or create an empty array and then add string elements to it.
In this example,
@string_array
using array literal syntax with predefined string values.@string_array = ("Hello", "World", "Perl");
print join(", ", @string_array);
Hello World Ruby
In this example,
@empty_string_array
.@empty_string_array = ();
push(@empty_string_array, "");
push(@empty_string_array, "");
push(@empty_string_array, "");
print join(", ", @empty_string_array);
, ,
In this tutorial, we learned How to Declare a String Array in Perl language with well detailed examples.