When I run my file opening perl script to open a Notepad text file, the interpreter's throwing the exception below, and I'm stumped as to how I can remedy this. Here's my source first:
#!/usr/bin/perl # nlexample.plx # The script opens a text file, reads it, prints a number and # then each line within the file. use warnings; use strict; use diagnostics; open FILE, 'C:\Perl\Perl practice\test.txt' or die $!; my $lineno = 1; while(<FILE>) { print $lineno++; print ": $_"; }
Here's the text file:
One day you're going to have to face
   A deep dark truthfull terror,
And it's gonna tell you things that I still
   Love you too much to say.
####### Elvis Costello, Spike, 1988 #######
And the expected response:
1:One day you're going to have to face
2:   A deep dark truthfull terror,
3:And it's gonna tell you things that I still
4:   Love you too much to say.
5:####### Elvis Costello, Spike, 1988 #######

Problem:

1. Why is this exception occurring? Perl seems to be looking for the text file at the same location every time: how do I change this? Why is Perl looking for the test.txt file at this location? Must be a default setting.

I using DzSoft Perl Editor to write my dode, and running from by the DOS promted provided by the IDE.

Uncaught exception from user code: No such file or directory at C:\DOCUMENTS AND SETTINGS\RICHARD LAMB \L +OCAL SETTINGS\Temp\dir11.tmp\nlexample.plx line 8
Very odd place for Windows to look for the files, as there”¦s no such file as ”„dir11.tmp”¦ when I look through the directory structure in Windows Explorer. Grrr. ƒ¼

Windows seems to be looking for a temp file containing the perl source: what the hell is going on?!

Solution: Locating the test.txt file in local settings?

edited: Thu Jul 24 00:37:03 2003 by jeffa - code tags formatting


In reply to Re: Re: Intercharacter spacing by Tricky
in thread Intercharacter spacing by Tricky

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.