substr won't include any spaces if your original source string doesn't have any. At any rate, just make an array out of your source string and use what I showed above.
my @src;
{
my $tmp = $a;
push @src, substr( $tmp, 0, 7, "" ) while $tmp;
}
# . . . as above . . .
Update: And looking again at your sample it appears you might have rows of space separated data, in which case you'd want to use something along the lines of while( <SRC> ) { chomp; push @src, split( /\s+/, $_) } to build @src. Sample data in <code> tags would help clear things up.
|