next up previous
Next: Reading Directories Up: Some useful Perl Previous: Substitution

Spilt() and join()

Spilt() and join() are two very useful functions.

Spilt() takes a regular expression and a string (split(reg_ex,string)) and looks for all occurrences of the regular expression and the parts of the string that don't match are returned, in sequence, in a list.

Therefore to split an input name/value pair CGI input we could do:

$cgi_pair = "name=value"; #format of input
($name,$value) = split(/=/,$cgi_pair);
@cgi_list =  = split(/=/,$cgi_pair);

The join() function takes two list values glues them together.



Dave Marshall
9/28/2001