Bee wrote:
I'd do a little add on for the string, so it much easier for split.
# usuw;
my $line = "M:356 358 386 R:#132 W1:319 NRT:32 R:#132";
print $line . "\n";
$line =~ s/(\s)(\w{1,}:)/\x00$2/g; # So I add extra delimiters here.
print $line . "\n";
my @d = split /\x00/, $line;
print "<$_> " for @d;
But only if you sure that char is not exist with the data string,
you can use. Otherwise, use other approach, or other delimiter.
Other approaches:
my @y;
push @y, "$1 $2" while $line =~ /(\w+):([^A-Z]+)(?: |$)/g;
or
my @y = map { tr/:/ /; $_ } $line =~ /(\w+:[^A-Z]+)(?: |$)/g;
Also, why is $y[0] undefined or null, scalar (@y) is 6.
That's explained in "perldoc -f split".
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>