How to initialize an array of Strings in Perl?

Posted by Joys of Programming on in Perl

The simplest method to initialize a string in Perl is in the following manner


my @day = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');

print $day[6];

which generates the following output


Saturday

If you notice carefully, each string is put in the quotes and separated by a comma

Reblog this post [with Zemanta]


Tags: ,

Comments:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2009-2012 Joys of Programming All rights reserved.
Desk Mess Mirrored v1.8.1 theme from BuyNowShop.com.