pulling or getting perl script name inside script

Discussion in 'Perl Misc' started by J M, Nov 6, 2004.

  1. J M

    J M Guest

    I have writeLog sub across several perl scripts that I use to generate logs
    from scripts. I like to put script name in side log. Until now I have been
    manually putting script name in writeLog sub but is there a way to pull
    script name dynamically so I don't have to use static script names inside
    perl script? TIA!
     
    J M, Nov 6, 2004
    #1
    1. Advertisements

  2. "J M" <> wrote in
    news:h2Xid.22397$:

    > I have writeLog sub across several perl scripts that I use to generate
    > logs from scripts. I like to put script name in side log. Until now I
    > have been manually putting script name in writeLog sub but is there a
    > way to pull script name dynamically so I don't have to use static
    > script names inside perl script? TIA!


    D:\Home> cat I_ought_to_read_the_docs_before_posting
    print "$0\n";

    D:\Home> perl I_ought_to_read_the_docs_before_posting
    I_ought_to_read_the_docs_before_posting

    Specifically, perldoc perlvar

    Sinan
     
    A. Sinan Unur, Nov 6, 2004
    #2
    1. Advertisements

  3. J M <> wrote:

    > is there a way to pull
    > script name dynamically



    No need to "pull" it from anywhere, it is already sitting there
    in a scalar variable, waiting for you to use it.

    A friendly Perl program:

    print 'Hi ', scalar(getpwuid($>)), ". My name is $0. How are you today?\n";
    # ^^
    # ^^ program name


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Nov 6, 2004
    #3
    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. Wet Basement
    Replies:
    1
    Views:
    2,796
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    2,153
  3. pj
    Replies:
    3
    Views:
    447
  4. Petterson Mikael

    Execute another perl script from my perl script

    Petterson Mikael, Jan 5, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    275
    Paul Lalli
    Jan 5, 2005
  5. Replies:
    20
    Views:
    1,297
    Gunnar Hjalmarsson
    Jan 18, 2005
  6. Replies:
    6
    Views:
    271
    Tad McClellan
    Apr 14, 2005
  7. vikrant
    Replies:
    4
    Views:
    441
  8. PhEaSaNt PLuCKeR

    perl script to pass data to another perl script?

    PhEaSaNt PLuCKeR, Oct 30, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    268
Loading...