How to initialize an array of String using Perl qw()
Posted by Joys of Programming on in Perl
The perl function qw() is the simplest way by which strings can be initialized.
my @day1 = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
my @day2 = qw (Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
print $day1[6];
See how day1 and day2 are initialized. qw does not require each string to be declared in quotes and separated by commas
Comments:
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=d4742d37-a178-409b-a613-9a6c5d9e96e8)