How do I reference myself?

D

D. Alvarado

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
 
P

Paul Lalli

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:


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
 
T

Tulan W. Hu

D. Alvarado said:
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:


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

print "$0\n";
 
A

A. Sinan Unur

(e-mail address removed) (D. Alvarado) wrote in
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:


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__
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top