Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: conditional self-execution

by apotheon (Deacon)
on Jan 28, 2008 at 03:27 UTC ( [id://664618]=note: print w/replies, xml ) Need Help??


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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://664618]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-26 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found