The road to perdition is paved with good intentions. ...I used to think that was true until I saw someone tie a file, and then open the same file for input before ever untieing it.

Seriously though, that's a shady thing to be doing, don't you think? You're exposing your script to the nuances of buffering. Nevertheless, your script isn't doing any writing, so buffering seems to not be at play here.

However, when I ran your script, I got the following message:

Can't locate object method "TIEARRAY" via package "Tie::File" at C:\Pe +rl\scripts\mytest.pl line 11.

...That's the error I got, until I remembered that you can't very well use Tie::Array without first having a line near the top of the script that says, "use Tie::Array;". Oops. Putting that line where it belongs in your script was all it took for it to "work".

Your riddle was made just a little more difficult to solve because you chose to tell us "I've got one machine where the script works, and one where it doesn't.", instead of helping us out by telling us what error and/or results you got. That would have been helpful information. Since I have to guess that your results were similar to mine, I have to wonder if the real riddle isn't how you got the script to work on the other machines without the important line, "use Tie::File;"

Update:

However, if by chance that isn't your problem, I would also look into the possibility of failing to convert your line endings when moving the script from a Windows environment to a Unix/Linux environment. That can cause a failure as well. Post your error message and we'll have a better idea of what's actually at play here. ...or don't post it and just keep us guessing. ;)


Dave


In reply to Re: Tie::File is sucking the life out of me by davido
in thread Tie::File is sucking the life out of me by GaijinPunch

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.