Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-28 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found