G
G
Hi, I'm a newbie to Perl and find regular expressions a mystery.
Anyway, I need to parse a file and display information in an HTML
file. My problem is that I don't know how to parse this stuff. Below
is the sample file showing 2 entries. After that I list my problem
code snip.
Thanks
"Title1" "Title2
" "Page:1" "Date: 12/15/2003 " "Time: 11:28:05AM
" "Sale
Number
" "
Sale Type
" "
Date Assigned
" "
Company Name
" "S034521" "Software Agreement" 11/08/2003 "Joes Garage" "2 Years
support"
"Title1" "Title2
" "Page:1" "Date: 12/15/2003 " "Time: 11:28:05AM
" "Sale
Number
" "
Sale Type
" "
Date Assigned
" "
Company Name
" "S034522" "Hardware" 12/11/2003 "JK & J INC." "Backup Tape"
while (<FILE>) {
#HERE IS WHERE I AM HAVING MY PROBLEM - I can't get a match
if ( ($snum, $type, $date, $comp_name) =
/\"+\"\t+\"+\"\t+\"+\"\t+\"+\"\t+\"+\"\t+\"(.+)\"\t+\"(.+)\"(.+?)\"(.+)\"\s*$/ix
) {
if ($snum !~ /^d/i) { next; }
$date =~ s/^\t*//; $date =~ s/\t*$//;
($ddate) = split(/\t/, $date);
$ddate = " " if (! $ddate);
$_ = <FILE>;
($description) = /^\"(.+)\"\s*$/; # dnum
if ($type !~ /^\s*$/) {
$output .=
PutRec($snum, $type, $ddate, $comp_name, $description);
}
}
}
Anyway, I need to parse a file and display information in an HTML
file. My problem is that I don't know how to parse this stuff. Below
is the sample file showing 2 entries. After that I list my problem
code snip.
Thanks
"Title1" "Title2
" "Page:1" "Date: 12/15/2003 " "Time: 11:28:05AM
" "Sale
Number
" "
Sale Type
" "
Date Assigned
" "
Company Name
" "S034521" "Software Agreement" 11/08/2003 "Joes Garage" "2 Years
support"
"Title1" "Title2
" "Page:1" "Date: 12/15/2003 " "Time: 11:28:05AM
" "Sale
Number
" "
Sale Type
" "
Date Assigned
" "
Company Name
" "S034522" "Hardware" 12/11/2003 "JK & J INC." "Backup Tape"
while (<FILE>) {
#HERE IS WHERE I AM HAVING MY PROBLEM - I can't get a match
if ( ($snum, $type, $date, $comp_name) =
/\"+\"\t+\"+\"\t+\"+\"\t+\"+\"\t+\"+\"\t+\"(.+)\"\t+\"(.+)\"(.+?)\"(.+)\"\s*$/ix
) {
if ($snum !~ /^d/i) { next; }
$date =~ s/^\t*//; $date =~ s/\t*$//;
($ddate) = split(/\t/, $date);
$ddate = " " if (! $ddate);
$_ = <FILE>;
($description) = /^\"(.+)\"\s*$/; # dnum
if ($type !~ /^\s*$/) {
$output .=
PutRec($snum, $type, $ddate, $comp_name, $description);
}
}
}