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

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

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

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. Rob Meade
    Replies:
    4
    Views:
    517
    Rob Meade
    Dec 3, 2003
  2. newgenre
    Replies:
    1
    Views:
    398
    Kevin Spencer
    Apr 7, 2004
  3. =?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:
    922
    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
    Oct 19, 2005
  4. Esco
    Replies:
    2
    Views:
    384
    Alex Hunsley
    Oct 2, 2004
  5. Joe Patrick

    Messages to Myself

    Joe Patrick, Aug 31, 2003, in forum: HTML
    Replies:
    6
    Views:
    841
    Joe Patrick
    Sep 3, 2003
  6. blar
    Replies:
    13
    Views:
    977
    Karl Core
    Dec 20, 2004
  7. JustSomeGuy

    I've painted myself into a corner!

    JustSomeGuy, Jun 22, 2004, in forum: C++
    Replies:
    4
    Views:
    534
    Dietmar Kuehl
    Jun 23, 2004
  8. digger440uk
    Replies:
    3
    Views:
    583
    Peter Flynn
    Jun 3, 2006
Loading...