CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: about "split": Edit Log



Jasmine
Administrator / Moderator

Apr 22, 2001, 8:19 PM


Views: 10373
Re: about "split"

I think what zanardi was trying to say is that you don't need to split arrays because they're already "split" and indexed.


Code
my @array = ("zero", "one", "two", "three");

are four separate elements of @array, whose values can be retrieved by their index.


Code
my @array = ("zero", "one", "two", "three"); 

print $array[3]; # prints three

The thing to remember about arrays is that the index number of the first element (in this case, one) is 0.

You can split strings using split, so if your string looked like:


Code
my $string = "zero,one,two,three";

You can use split to put each element into its own array.


Code
my @array = split(/,/, $string );

Hope this helps!



(This post was edited by Jasmine on Apr 23, 2001, 5:54 PM)


This post has not been edited


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives