#!/usr/bin/perl -w use strict; my $str = "x:= y + z;"; my @tokens = split /\s+|(?<=\w)(?=(?:;|:=))/, $str; print join "\n", @tokens;