in reply to Re: Assigning scalar to each field in a flat file database
in thread Assigning scalar to each field in a flat file database

Hi, thanks for the post, still having heartache! my text file looks like this:
data|data1|data2|<BR> data3|data4|data5|data6<BR><BR> and so forth...there are about 87 fields split in no particular order +over 28 lines. So, what am I doing wrong? I am getting an internal +server error when I use the following code:<BR><BR> #!/usr/bin/perl -w<BR> print "Content-type:text/html\n\n";<BR> open (DATA, "<../../cgi-bin/tracking_1_db.txt") || die;<BR> while (<DATA>) {<BR> my @items = split (/|/, $_);<BR> }<BR> close (DATA);<BR> <HTML><BR> <HEAD><BR> <TITLE>Perl Test Script 1</TITLE><BR> </HEAD><BR> <BODY><BR> $items[0];<BR> $items[1];<BR> </BODY><BR> </HTML><BR>

Replies are listed 'Best First'.
Re: Re: Re: Assigning scalar to each field in a flat file database
by BeernuT (Pilgrim) on Mar 09, 2002 at 03:40 UTC
    Well you kinda missed/ignored the code i posted. The split function takes a regular expression /PATTERN/ and in a // the character '|' is an 'or'. So use /\|/ instead.
    @array = split(/\|/, $_);
    That should help you out a little more.

    -bn