In article <[EMAIL PROTECTED]>,
        Peter Makholm <[EMAIL PROTECTED]> writes:
> [EMAIL PROTECTED] (Ton Hospel) writes:
> 
>> This is not the first time I've been wondering about the exact form of $0.
>> I'd also like a judgement if `$0 args` is allowed (probably not ok),
>> and even `$^X $0 args` (probably ok).
> 
> It is usual with something like the following rule:
> 
>  - The program may only use the perl executable, no other executables
>    on the system are allowed (the program may use itself though). You
>    may use any of the perl 5.6.1 standard core modules (perldoc
>    perlmodlib for a list of those core modules). Your solution must be
>    portable in the sense that it should work on all versions of 5.6.1
>    everywhere (however, it's perfectly fine to abuse perl 5.6.1 bugs).
> 
>  - When tested, your script will be named anagrams.pl, and you must
>    assume your script to have file permissions of 0644 (ie,
>    non-executable for windows folks).
> 
> 
> So you are allowed to execute $^X and you can read and write $0. So
> you're right in that `$0~ isn't ok while `$^X $0` is.

It's not enough. While indeed this excludes `$0 args` in general (even 
though that would in fact work on windows), it's in fact not guaranteed
that $0 contains a valid representation of the programname. So 
`$^X $0 args` is in fact still not absolutely certain to work (nor even
the sometimes used do$0). Even if it does, you cannot determine from this 
description how $0 will look, since it's still not clear if it will 
contain a directory component, so you still cannot determine if e.g. 
the given 37 is valid or not.

I've for example wondered at another time if ./$0 will represent the 
program (will fail if $0 is an absolute path. Can it happen ?)

Reply via email to