×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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, "<rawdata.txt");

while(<READIN>){
    chomp;
    $line = $_;
    @records = split(/|/, $line);
    print "\n\n@records\n\n";
    print "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";
}


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

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

(OP)
oops, thx for looking, but hte pipe has to be escaped to work, so it's

split(/\|/)...

boy, i feel dumb...

MWB

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close