This program 

#!/usr/bin/perl -w

use strict;
while (<DATA>) {

chomp;
my $line = $_;

my @y =split (/\b[\w]+:/,$line);

#print scalar(@y);
print $line;
print "\n\$y[0] $y[0]\n\$y[1] $y[1]\n\$y[2] $y[2]\n\$y[3] $y[3]\n\$y[4] $y[4]\n\$y[5] 
$y[5]\n";
} 

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



produces 

[EMAIL PROTECTED] PerlScripts]$ perl  split.test
M:356 358 386 R:#132 W1:319 NRT:32 R:#132
$y[0]
$y[1] 356 358 386
$y[2] #132
$y[3] 319
$y[4] 32
$y[5] #132



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


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


TIA for any clues



-- 
Owen



-- 
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