in reply to Re: Finding out how you were called...
in thread Finding out how you were called...

Ahhh! $0 does... that's my bad for assuming argv[0] in c and $0 in perl contained the same values... is that just a perl thing, because it is a script called in the interpreter? How does perl find that data, and what is the way in C (If anyone knows... I realize this is perlmonks, not cmonks :) Thanks, tho... I want to do this in perl and C, but if it only works in perl, oh well :)

                - Ant
                - Some of my best work - Fish Dinner

Replies are listed 'Best First'.
(tye)Re: Finding out how you were called...
by tye (Sage) on Aug 07, 2001 at 10:16 UTC

    Don't feel bad. An entire module has sprung up based on this same misconception (and it was authored by some of the top Perl guys around). $0 is the name of the script, which Perl has to be able to open so Perl knows the correct path to it and doesn't hide it from you. argv[0] in the C code that implements Perl is "...perl" (not the script name) and may not have a full path and so $^X may not have a full path. See FindBin is broken (RE: How do I get the full path to the script executing?) for more.

            - tye (but my friends call me "Tye")
Re^3: Finding out how you were called...
by tadman (Prior) on Aug 07, 2001 at 04:45 UTC
    It would seem that Perl processes its own argv[0] to make it all nice and easy for you to do what you want. This is not something that happens all by itself in C programs. C does, to a certain degree, leave you up to your own devices. So, evaluating your path for a possible match is something to consider doing, perhaps with strtok on a copy of your $PATH.