Not really related to gaal's problem - except for the "Can't be!" part - but I thought I'd share this little episode which happened to me some time ago.

I'd been hacking at the Perl interpreter to create a modified version for a special purpose (details irrelevant here). When I was done, I thought it would be a good idea to rename the binary from "perl" to "plc", to make it clear to me and anyone else that this is not a normal perl. Consequently, I installed this version under /usr/local/plc/..., together with the usual symlink /usr/local/bin/plc pointing to the binary.

To play with this new toy, I had put the shebang line #!/usr/local/bin/plc in my little test script, and the first tests looked good so far. But as my script grew larger, weird things started to happen. Of course, my first thought was "Ok, Almut, you've messed it up!", or at least - with less detrimental effects on my self-esteem - "there's still room for improvement in your initial hacking attempts".

To verify this hypothesis, I quickly went to check whether my test script would still be working as expected when run with the normal (unchanged) Perl. In cases like these, I usually call the desired version explicitly, to avoid having to edit the shebang line. So, I typed - full path to be absolutely sure - /usr/local/bin/perl test_script.pl   Nothing special really. I had done this hundreds of times before, as I usually have several versions of Perl to play with. (Unless you mess with other things, the respective perl binary has no problem finding everything else that belongs to it...)

Somewhat to my surprise, my script's behaviour didn't change. Same weirdness ... Can't be! But after a couple of "Hmm, I could've sworn I'd written code like this before which worked", I then went on to rewrite the problematic code, which wasn't all that difficult, thanks to Perl's TIMTOWTDI. And things were fine again. Until strangeness kept creeping in again and again while doing further tests. At this point, I would've had to seriously question my general Perl coding abilities, so I figured there must be some other explanation... ;)

Well, to make it short, after lots of strace-ing, losing trust in my sanity, etc., I finally found this little paragraph while perusing the output of perldoc perlrun

If the #! line does not contain the word "perl", the program named after the #! is executed instead of the Perl interpreter. This is slightly bizarre, but it helps people on machines that don't do #!, because they can tell a program that their SHELL is /usr/bin/perl, and Perl will then dispatch the program to the correct interpreter for them.

And my almost infinite ignorance had suddenly been reduced to almost_infinite - 1.

The moral of the story: Thou shalt not dispossess Perl of its proper name, or its wrath and black magic will come down on thee like a ton of bricks :)


In reply to Re: "Can't happen" bugs by almut
in thread "Can't happen" bugs by gaal

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.