How do I reference myself?

Discussion in 'Perl Misc' started by D. Alvarado, Mar 2, 2004.

  1. D. Alvarado

    D. Alvarado Guest

    Hello,
    From within my perl script, I want to be able to print my file
    name. For example, if my file were named "test.pl", I'd link to see:

    > perl test.pl
    > test.pl
    >


    print out. I am on Solaris, but I'd prefer the solution be OS
    independent. Thanks - Dave
     
    D. Alvarado, Mar 2, 2004
    #1
    1. Advertising

  2. D. Alvarado

    Paul Lalli Guest

    On Tue, 2 Mar 2004, D. Alvarado wrote:

    > Hello,
    > From within my perl script, I want to be able to print my file
    > name. For example, if my file were named "test.pl", I'd link to see:
    >
    > > perl test.pl
    > > test.pl
    > >

    >
    > print out. I am on Solaris, but I'd prefer the solution be OS
    > independent. Thanks - Dave
    >


    print "$0\n";


    you need to read perldoc perlvar

    Paul Lalli
     
    Paul Lalli, Mar 2, 2004
    #2
    1. Advertising

  3. D. Alvarado

    Tulan W. Hu Guest

    "D. Alvarado" <> wrote in message ...
    > Hello,
    > From within my perl script, I want to be able to print my file
    > name. For example, if my file were named "test.pl", I'd link to see:
    >
    > > perl test.pl
    > > test.pl
    > >

    >
    > print out. I am on Solaris, but I'd prefer the solution be OS
    > independent. Thanks - Dave


    print "$0\n";
     
    Tulan W. Hu, Mar 2, 2004
    #3
  4. (D. Alvarado) wrote in
    news::

    > Hello,
    > From within my perl script, I want to be able to print my file
    > name. For example, if my file were named "test.pl", I'd link to see:
    >
    >> perl test.pl
    >> test.pl
    >>

    >
    > print out. I am on Solaris, but I'd prefer the solution be OS
    > independent. Thanks - Dave


    You should look at the documentation before posting here:

    perldoc perlvar

    ###
    use strict;
    use warnings;

    use File::Basename;

    print basename($0);
    __END__

    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, Mar 2, 2004
    #4
  5. D. Alvarado

    Cyde Weys Guest

    "I"
     
    Cyde Weys, Mar 2, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Garcia Aprea [MVP]

    Re: Howto catch HttpRequestValidationException myself

    Victor Garcia Aprea [MVP], Jul 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    521
    Victor Garcia Aprea [MVP]
    Jul 12, 2003
  2. John Saunders
    Replies:
    0
    Views:
    460
    John Saunders
    Jul 23, 2003
  3. Rob Meade
    Replies:
    4
    Views:
    389
    Rob Meade
    Dec 3, 2003
  4. newgenre
    Replies:
    1
    Views:
    325
    Kevin Spencer
    Apr 7, 2004
  5. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    Please save me from shooting myself in the head!

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Oct 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    807
    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
    Oct 19, 2005
Loading...

Share This Page