On Wed, 22 Jun 2005, Ing. Branislav Gerzo wrote:

> Bret Goodfellow [BG], on Wednesday, June 22, 2005 at 15:11 (-0600)
> typed the following:
> 
> BG> All right, I know how to do this in REXX because there is a word()
> BG> function, but how do I do this in Perl.  I want to read in one record at
> BG> a time, that has space-delimited fields.  There may be multiple spaces
> BG> between the words.  I want to be able to get for example, the 4th word
> BG> of the record.  How do I do this?  Just for grins, my record looks like
> BG> this:
>  
> BG> /dev/sun11/lvol13   1032192  377921  613445   38% /techsupp
> 
> use regular expressions, for example like this:

No, not like that. A regex in a split will be easier. 

  my $fields = split( /\s+/, $record );
  my $fourth = $fields[3];
 
This problem doesn't require any looping! :-)

 

-- 
Chris Devers

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