http://www.perlmonks.org?node_id=664618


in reply to Re: conditional self-execution
in thread conditional self-execution

Nope, didn't try it -- because in Ruby, __FILE__ is a variable (or constant, or something to that effect, unless I'm grossly mistaken), and in Perl it cannot be a variable thanks to the fact there's no leading sigil. I guess maybe I should have tried it anyway, on the wild-ass guess that maybe it'd magically work somehow regardless of my apparently false assumptions.

I'd been searching for anything and everything I could think to search for that might give such information, using Google, since it didn't occur to me that there'd be a whole class of variable-like things called "special literals" in Perl.

Anyway, thanks for pointing that out.

print substr("Just another Perl hacker", 0, -2);
- apotheon
CopyWrite Chad Perrin

Replies are listed 'Best First'.
Re^3: conditional self-execution
by GrandFather (Saint) on Jan 28, 2008 at 03:33 UTC

    It's the C legacy ya know ;).


    Perl is environmentally friendly - it saves trees

      An entire category of entities just for three pseudo-constants, for hysterical purposes thanks to C legacy. Yeah. I think that qualifies as a wart on the language.

      . . . but I still do love my Perl so. Thanks again.

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin

        I personally believe you may be glad to know -just for the record- that in full respect to the principle of least surprise, in Perl 6 "this kinda things" will actually be made regular variables of an appropriate namespace, with an appropriate sigil, and an appropriate twigil.

        --
        If you can't understand the incipit, then please check the IPB Campaign.
Re^3: conditional self-execution
by Anonymous Monk on Jan 28, 2008 at 08:10 UTC
    actually, __FILE__ is exactly the same thing in perl: a variable, a constant, or something else.
      exactly the same thing in perl

      When you misquote me ("something else" instead of what I actually said: "something to that effect"), that sure does seem like it's the case.

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin

        __FILE__ is exactly the same thing in perl: a variable, a constant, or something else.

        Except that it cannot be interpolated (not unreasonably).