<snip>
> __DATA__
> M:356 358 386 R:#132 W1:319 NRT:32 R:#132
>

<snip>
>
> but I would really like it to capture the first part of the element so
that the result would be;
>
> M:356 358 386 R:#132 W1:319 NRT:32 R:#132
> $y[0]
> $y[1] M 356 358 386
> $y[2] R #132
> $y[3] W1 319
> $y[4] NRT 32
> $y[5] R #132
>

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.

>
> Also, why is $y[0] undefined or null, scalar (@y) is 6.

I don't know how to tell, but I think you want \s , but not \b.

HTH,
Bee



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to