Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] RE: Program name from $0 on Unix

Expand Messages
  • hyperbola
    How about this: $progname = $0; $progname =~ s#.*/##g; cheers, -hyperbola ... __________________________________________________ Do You Yahoo!? Tired of spam?
    Message 1 of 4 , Dec 29, 2004
    • 0 Attachment
      How about this:

      $progname = $0;
      $progname =~ s#.*/##g;

      cheers,
      -hyperbola

      --- "Madani, Srikanth, VF-DE"
      <srikanth.madani@...> wrote:

      > Hi all,
      >
      > Probably the most trivial of things - I want to
      > extract the name of the Perl program file from the
      > contents of the $0 variable, given that the program
      > is being executed on a Unix machine.
      >
      > The following snippet worked:
      >
      > my @ProgramName = split /\//, $0;
      > $0 = $ProgramName[$#ProgramName];
      >
      > Is there a more stylish way of doing this or is
      > there a widely accepted code snippet (given that it
      > is such a basic task)?
      >
      > Cheers,
      > Srikanth Madani
      > D�sseldorf
      >
      >
      >


      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.