Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: conditional self-execution

by GrandFather (Sage)
on Jan 28, 2008 at 03:12 UTC ( #664613=note: print w/replies, xml ) Need Help??


in reply to conditional self-execution

umm, __FILE__ (did you try it?).

Update: the Special Literals section in perldata provides the documentation for it - not my first guess I must admit.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^2: conditional self-execution
by apotheon (Deacon) on Jan 28, 2008 at 03:27 UTC

    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

      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

      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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2020-12-01 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?