Basic HTML version of Foils prepared March 30 97

Foil 46 Split and Join Operators
(Chapter 7 of the Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


1 split takes a line and splits into parts which are separated by a delimiter defined as any regular expression. For example
2 @fields = split(/\s/,$line); # splits string $line into several fields stored in $field[0] $field[1] etc. where these fields were separated by white space (\s) in $line
3 join inverts the operation although the join string must now be an ordinary single or double quoted string and not a regular expression as no matching is occuring!
4 $line = join( " \t", @fields); # rebuilds $line with space and tab as separator.

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Sep 6 1997