schulerlab has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: difference between tie with and without parentheses
by BrowserUk (Patriarch) on Jul 30, 2008 at 03:40 UTC | |
|
Re: difference between tie with and without parentheses
by ikegami (Patriarch) on Jul 30, 2008 at 00:34 UTC | |
|
Re: difference between tie with and without parentheses
by AltBlue (Chaplain) on Jul 30, 2008 at 02:58 UTC |