Text Processing Functions

The split function

Definition

The split function splits a string to a list of substrings according to the positions of a given delimiter. The delimiter is written as a pattern enclosed by slashes: /PATTERN/.

Examples:


You can assign the result of the split function to an array containing a list of scalar variable names.

Example:

$string = "protein kinase C\t450 Kilodaltons\t120 Kilobases";
($name, $mol_weight, $seq_length) = split (/\t/, $string);

# Now $name contains       "protein kinase C"
      $mol_weight contains "450 Kilodaltons" and
      $seq_length contains "120 Kilobases".


Table of Contents.
Previous | Next.