Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy split() problem but I"m stumped...

Status
Not open for further replies.

mbaranski

Programmer
Nov 3, 2000
421
US
For some reason, this code does not split the file by pipes, it splits each character into a seperate part of the array, I've also included a sample record from the file. Any ideas?

open(READIN, &quot;<rawdata.txt&quot;);

while(<READIN>){
chomp;
$line = $_;
@records = split(/|/, $line);
print &quot;\n\n@records\n\n&quot;;
print &quot;INSERT INTO EMP_TEST2 VALUES ((TO_DATE(\'04-DEC-2000\', \'DD-MON-YYYY\')),
\'A\',
(TO_DATE(\'$records[1]\', \'DD-MON-YYYY\')),
(TO_DATE(\'$records[2]\', \'DD-MON-YYYY\')),
\'$records[3]\',
\'$records[4]\',
\'$records[5]\',
\'$records[6]\',
\'$records[7]\',
\'$records[8]\',
\'$records[9]\',
\'$records[10]\',
\'$records[11]\',
\'$records[12]\',
(TO_DATE(\'$records[13]\', \'DD-MON-YYYY\')),
\'$records[14]\',
\'$records[15]\',\'$records[16]\',\'$records[17]\',\'$records[18]\',\'$records[19]\',\'$records[20]\',\'$records[21]\',\'$records[22]\',\'$records[23]\',\'$records[24]\',\'$records[25]\',\'$records[26]\',\'$records[27]\',\'$records[28]\',\'$records[29]\','N');\n\n&quot;;
}


Sample Record:
A|08-FEB-1985||000010|Alan|Biggs|3415 22Nd St|#5|San Francisco|CA|94110|USA|415/821-9943|04-FEB-1947|Personal Banker|800064|Deposit Sales & Service/SF|160 Spear St.| | |San Francisco|CA|94105|USA| |160 Spear|Walker,Antoinette L|David Biggs|415/431-9902
 
oops, thx for looking, but hte pipe has to be escaped to work, so it's

split(/\|/)...

boy, i feel dumb...

MWB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top