> 
> Hello all,
>  
> I have a line of text and numbers each seperated by multiple or single
> spaces  looks like this
>  
> abc   123  33545      789
>  
> I wanted to split the above line and store each column value in a specific
> variable and later print,
>  
> Below is the code I am using but it's not working as I desire,
>  
>  $Avg=$first[$i];
>          chomp($Avg);
>          ($label,$TD,$YT,$M,$L,$Y,$W)= split (/i\s*/,$Avg);
>           print "$label,$TD,$YT,$M,$L,$Y,$W\n";
>  
> I used "\s*" in split, so I do not have worry about counting the spaces or
> tabs between each field
>

What do you think the 'i' is doing in the regexp above?  You are saying
to match the letter 'i' followed by zero or more spaces.  Removing the
'i' will cause a match on every non-whitespace character.  You want to
split on 1-or-more white space characters. Try /\s+/ as your pattern
instead.
  
> Any suggestions on what am I doing wrong..?
>  

I assume your data can have as many fields as you split into?

http://danconia.org

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