in reply to Eliminating leading spaces
This should print: a b c#! /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"; }
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
|
|---|