Re: [MacPerl-WebCGI] I'm out standing in my field, duh!
[email protected] (Bruce Van Allen) Mon, 5 Mar 2001 18:41:55 -0800
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <p05010401b6c9fd118509@[205.179.215.44]> |
At 8:38 PM -0500 3/5/01, tedd wrote:
>Hi:
>
>I'm trying to open and read a data file on a server. The data file
>is a tab/carriage-return delimited file (consisting of fields
>separated by tabs and records separated by carriage-returns).
>
>When I use the following code --
>
> open(DATA,$datafile) || &open_error($datafile);
> while (defined($_ = <DATA>))
> {
> for (split)
> {
> @line = split(/\t/, $_); #tab
>and returns
>
[snip]
> print "$item_number\n";
> print "<p></p>\n";
> }
> }
>
>-- it prints the entire contents of the file. However, so does the
>following code:
>
> open(DATA,$datafile) || &open_error($datafile);
> while (defined($_ = <DATA>))
> {
> for (split)
> {
> @line = split(/\t/, $_); #tab
>and returns
> $database_id = $line[0];
> }
> }
>
>What gives?
>
>I can't seem to dump the fields of the file into the variables I
>want. Everything
Try it this way:
while (<DATA>) {
@line = split /\t/; # $_ is implied
# ...
HTH
1;
--
- Bruce
__bruce_van_allen__santa_cruz_ca__