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;

In reply to array reading problem by jeah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.