Click here to get back home

A do-file location: how the code inside that do-file find it?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
A do-file location: how the code inside that do-file find it? S P Arif Sahari Wibowo 01-20-2008
Posted by S P Arif Sahari Wibowo on January 20, 2008, 12:32 am
Please log in for more thread options
Hi!

Let's say script A call a subscript B either by do, require, or
use. Now the code inside subscript B need to know what the file
location of subscript B. How this can be done?

The perldoc page of do mentioned that perl will keep track the
file name (e.g. for error reporting), how to get access to this
file name recorded by perl?

Thanks!

--
(stephan paul) Arif Sahari Wibowo
_____ _____ _____ _____
/____ /____/ /____/ /____
_____/ / / / _____/ http://www.arifsaha.com/

Posted by Gunnar Hjalmarsson on January 20, 2008, 1:28 am
Please log in for more thread options
[ followup set to comp.lang.perl.misc ]

S P Arif Sahari Wibowo wrote:
> Let's say script A call a subscript B either by do, require, or use. Now
> the code inside subscript B need to know what the file location of
> subscript B. How this can be done?
>
> The perldoc page of do mentioned that perl will keep track the file name
> (e.g. for error reporting), how to get access to this file name recorded
> by perl?

Read about the $0 variable in "perldoc perlvar".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Posted by Abigail on January 20, 2008, 7:11 am
Please log in for more thread options
_
S P Arif Sahari Wibowo (arifsaha@yahoo.com) wrote on VCCLV September
<> Hi!
<>
<> Let's say script A call a subscript B either by do, require, or
<> use. Now the code inside subscript B need to know what the file
<> location of subscript B. How this can be done?
<>
<> The perldoc page of do mentioned that perl will keep track the
<> file name (e.g. for error reporting), how to get access to this
<> file name recorded by perl?

say __FILE__;



Abigail
--
# Perl 5.6.0 broke this.
%0=mapABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$01$2$0$0$4":"$3 => $4\n"/xeg;print#Towers of Hanoi

Posted by S P Arif Sahari Wibowo on January 20, 2008, 12:54 pm
Please log in for more thread options
On Sun, 20 Jan 2008, Abigail wrote:
> say __FILE__;

Exactly what I need! Thanks!

--
(stephan paul) Arif Sahari Wibowo
_____ _____ _____ _____
/____ /____/ /____/ /____
_____/ / / / _____/ http://www.arifsaha.com/

Posted by Michele Dondi on January 22, 2008, 6:39 am
Please log in for more thread options
On Mon, 21 Jan 2008 15:02:46 -0800 (PST), "comp.llang.perl.moderated"

>I would have thought 'FindBin' (perldoc FindBin) would have been the
>best answer if the former.

OTOH FindBin is somewhat bugged.


Michele
--
->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Similar ThreadsPosted
default location for apache2.pm October 3, 2005, 11:39 pm
mod_perl -> Can't enable PerlResponeHandler in January 7, 2008, 7:06 am
can apache::filter work with virtual location? July 28, 2007, 10:36 pm
HTML::Template, is it possible to nest inside a ? June 4, 2007, 4:58 pm
Is it possible to use a custom perl binary inside a prebuilt apache/mod_perl environment? April 24, 2007, 5:15 pm
ANNOUNCE: Code::Dumper - a ::Dumper for code. Available on CPAN November 21, 2005, 11:03 am
Please help with this code June 10, 2007, 3:40 pm
Cant find pmtools December 9, 2004, 8:11 pm
What is endian.h? and How can I find it? February 15, 2005, 12:50 pm
find a first column value ... May 19, 2006, 12:54 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap