in reply to Re: Tie::File is sucking the life out of me
in thread Tie::File is sucking the life out of me

Sorry I didn't give enough info

0) use Tie::File;
Yes, it was in there from the begining. I didn't copy everything directly from the terminal, mainly b/c the data was sensitive. Sorry for the confusion. I figured since I mentioned I run the exact script flawlessly on other computers, that would be a given.

1) I only opened up the file with a filehandle for testing - to make sure the file was alive, readable, and all that jazz. The original script tied the file, and that's all. (the only filehandle was to write output)

2) Both machines are running version 0.93

3) There's no error. It runs through the script, but seeing as how my array I've tied the file to has -1 elements, it's not really going to do anything... nothing good anyway.

I guess that falls under the "keep you guessing" category.
  • Comment on Re: Re: Tie::File is sucking the life out of me

Replies are listed 'Best First'.
Re: Re: Re: Tie::File is sucking the life out of me
by davido (Cardinal) on Apr 27, 2004 at 07:24 UTC
    0) That makes a big difference, and is one possibility I suspected all along. Can you verify that the script you posted replicates the errant behavior? Because for me it doesn't. Since you're not showing us the actual code, it is encumbant on you to provide code that replicates the problem without introducing other bugs (ie, wild goose chases).

    1) Fine, but again we didn't know that. The fact is that your double-use of the same file isn't causing a problem in this case, it's just asking for trouble if you use it in production though. And we had no way of knowing that your test code introduced elements not present in your production code.

    2) Are both machines the same OS? If not, did you make sure to convert your line endings? I'm still keeping that one open as an option.

    3) I ran your script using a text file instead of an empty file. I also ran it with an empty file as you're doing. It worked fine both ways. So again I have to ask if this snippet you've provided replicates the errant behavior.

    As I said before, if you're dealing with different operating systems, ensure that you have converted your line endings.

    And jeffa may also be right, with the suggestion to ensure that on both of your machines, your script has permission to work with the file in question.


    Dave

      Okay, I figured it out. It was the permissions, even though anyone could read the file when I ran 'ls -ltr'.

      Is there something different about reading a file via file handle, as opposed to Tie::File? This is why I tried it the conventional way -- to see if I had permission to read the file.

      Anyways, thanks for the help.
        It seems unlikely that Tie::File is silently failing to open the file. Did your original code have the "or die..." part as part of the 'tie' statement?

        The permissions issue can crop up if your script has read-only permission. Tie::File by default tries to open for read/write. If you want it to open for read-only, you have to use the mode attribute when you initiate the tie.


        Dave