Basic HTML version of Foils prepared Sept 20 97

Foil 49 Split and Join Operators

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


split takes a string and splits it into parts separated by a delimiter, which may be any regular expression. E.g.,
@fields = split(/\s+/, $line); # splits string $line into several fields stored in $field[0] $field[1] etc. where these fields were separated by whitespace (\s) in $line
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!
$line = join( " \t", @fields); # rebuilds $line with space and tab as separator.



© 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 Sun Sep 21 1997