http://qs1969.pair.com?node_id=725397

jeah has asked for the wisdom of the Perl Monks concerning the following question:

Question (script at end of these notes):

* Why does my script give a result of '1' if I comment out line 6, using lines 4, 8 and 10?

* The script prints all my content correctly and completely if I comment out lines 4 and 8, using only lines 6 and 10.

The + signs in my script was automatically generated by this site, it's not part of my script. Thanks very much in advance for any help.

What I want to do:

Access a file's records whose individual attributes are delimited by pipes, the records themselves are separated by carriage returns/new line characters.

Desired Sequence:

1. Assign the file to a variable

2. Assign specific attributes of each record to various variables

3. For each record, pass the values in these variables into a T-SQL statement that updates/inserts various SQL Server tables.

Peripheral Notes:

- I'm running Perl on WinXP

- I already have the proper DBI module installed and code for the database connection and data manipulations

- The entire file's records are as follows (verbatim in content and format as the file's):

Baw|Vao|111 Noa St||NewYork|NY|10012|2123456789|123456789

Vca|Wxr|384 Mkl Ln|Xillo|CrrntStt|CT|05506|1015567781|1015567782

- In my script (for testing item 1 only), the file's content is also hardcoded for testing (line 6), it includes the following to mimic the actual file's format: . "\n" . my script follows:

#!/usr/xyz/perl -w use strict; my @r = open(DATFH, 'C:\begperl\my scripts\cdata.txt') or die "File pr +ob: $! \n"; #my @r = "Bao|Voa|321 st||New York|NY|2120001356|9172804972" . "\n" . +"Vca|Wxr|384 Mkl Ln|Xillo|Crrnt Stt|CT|05506|1015567781|1015567782"; close DATFH; print @r;