in reply to Eliminating leading spaces

Metadoktor's solution certainly will work, but I would like to offer one of my own.

#! /usr/bin/perl -Tw my ($label, $string); $string = "a1: a,b,c"; $string =~ s/\s+//g; # $string = a1:a,b,c ($label, $string) = split(/:/,$string); my @tokens = split(/,/,$string); foreach (@tokens) { print "$_\n"; }
This should print: a b c

However, you MIGHT also be asking exactly how to eliminate leading spaces. The '^' at the beginning of the regex points to the beginning of a line or string such that:

$string =~ s/^\s*//;

will get rid of leading spaces