during a recent upgrade, I kept getting the error "Inappropriate ioctl" when I would try to access a file that worked previously before the upgrade.

eventually, with a friend's help, we realized the problem was that the previous program used a different database method (because of a mod that I put in when the server that the site was on previously didn't have the default database method).

fine.. I deleted the old file, and let the upgraded program rebuild it.

However, my friend was trying different things related to this and another problem he had, and discovered that the TIE works differently depending on whether you use parentheses or not (and this is how he explained what he saw):

This is hard to explain. I'll try. This is what i observed:

When the script cannot open the existing database file (here, the file named 'messagelist',) for some reason it seems that the "tie() or Error" this is the same thing as: "tie() or die" section evaluates to a non-fatal termination and so the $! in Error sub returns a "blank":

/home/mysite/public_html/tarty/bbs/tigerT/messagelist :

Then, the messagelist somehow gets deleted (most likely by the Rebuild_Database sub.) So, when i refresh the screen to make a 2nd attempt of rebuilding the index, the $! in Error sub returns a "No such file or directory" error:

/home/mysite/public_html/tarty/bbs/tigerT/messagelist : No such file or directory

Now, i change the code and remove the parentheses from the tie command. That is, i change it from "tie() or die" to "tie or die". I then change the script to use another DBM file than DB_File (or the vice versa) and do a rebuild.

The script still cannot read the existing database file. But the "tie or die" section does Not evaluate to a termination. The script moves on to rebuild the database using the new DBM file and then replaces the old database file with the new one.

In most cases, the presence or absence of parentheses in a command doesn't make any differences. But in this case, it means a lot.

I only know this is the way it works but don't know why it works this way

why does the TIE work this way, and is there a writeup on the difference? We couldn't find any documentation on this.

thanks.

In reply to difference between tie with and without parentheses by schulerlab

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.