Why don't you just split the line and use the whitespace as separator?

$line =~ s/\s+/ /;
my ($record,$date,$cust,$temp1,$temp2,$temp3,$temp4,$temp5,$shipping,$paid)
= split (/ /,$line);



-----Original Message-----
From: Kevin Old [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 10:38 AM
To: [EMAIL PROTECTED]
Subject: Need help with regex

Hello everyone,

I have a line like the following:

my $line = "31232000 07/28/04 DUC000 NET 60 DAYS      RD    222264    
   UPSGNDSVR   PREPAID";

What I'm looking for in lines like this are the customer number
(DUC000) and a "code" that starts with UPS, or if the code doesn't
start with UPS idealy I'd like to have whatever was in that place
returned, but I can't figure that out and can settle for just nothing
returned along with the customer number.

The problem with the regex below is that if the shipping "code"
doesn't start with UPS, it doesn't return the custnum.

$_ =~ /\d+\s+\d+\/\d+\/\d+\s+(\w+).*(UPS\w+)\s/;
$custnum = $1;
$isups = $2;

I know I'm missing something basic.  I've even tried grouping it and
trying the zero or more matching:

$_ =~ /\d+\s+\d+\/\d+\/\d+\s+(\w+).*(?:(UPS\w+)\s)*/

This doesn't match anything.

Any ideas?  

Thanks,
-- 
Kevin Old
[EMAIL PROTECTED]

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



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