[23341] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5561 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 25 14:05:59 2003

Date: Thu, 25 Sep 2003 11:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 25 Sep 2003     Volume: 10 Number: 5561

Today's topics:
    Re: 1) How to debug CGI.pm cookies 2) Template.pm with  <konny@waitrose.com>
    Re: 1) How to debug CGI.pm cookies 2) Template.pm with  <konny@waitrose.com>
    Re: 1) How to debug CGI.pm cookies 2) Template.pm with  <tore@aursand.no>
    Re: 1) How to debug CGI.pm cookies 2) Template.pm with  <tore@aursand.no>
    Re: 1) How to debug CGI.pm cookies 2) Template.pm with  <flavell@ph.gla.ac.uk>
        A doubt (mani)
    Re: A doubt <jurgenex@hotmail.com>
    Re: Apache session <lionel.valero@polymtl.ca>
    Re: Apache session <lionel.valero@polymtl.ca>
        Bear trap in scoping rules (John Ramsden)
    Re: Bear trap in scoping rules <pinyaj@rpi.edu>
    Re: Bear trap in scoping rules <mpapec@yahoo.com>
    Re: Bear trap in scoping rules (Anno Siegel)
    Re: class methods <tore@aursand.no>
    Re: Compiling perl with GCC <Juha.Laiho@iki.fi>
        Easy way to replace 0 with empty string? <rubberducky703@hotmail.com>
    Re: Easy way to replace 0 with empty string? <ak+usenet@freeshell.org>
    Re: Easy way to replace 0 with empty string? <usenet@dwall.fastmail.fm>
    Re: Easy way to replace 0 with empty string? (Anno Siegel)
    Re: Easy way to replace 0 with empty string? <grazz@pobox.com>
    Re: Easy way to replace 0 with empty string? <postmaster@castleamber.com.invalid>
        getcwd or similar <amoroder@sb-brixen.[nospam]it>
    Re: getcwd or similar <jurgenex@hotmail.com>
    Re: getcwd or similar <ak+usenet@freeshell.org>
    Re: getcwd or similar <no.name@eidosnet.co.uk>
    Re: getcwd or similar <Juha.Laiho@iki.fi>
        How to go up trace stack in debugger? <jill_krugman@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 25 Sep 2003 16:34:52 +0100
From: Mr I <konny@waitrose.com>
Subject: Re: 1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm
Message-Id: <ujeb41-q4q.ln1@sam.amaretti.net>

Mr I wrote:
> Hi all,
> I would like so help on 2 issues
> 
> 1) debugging CGI.pm cookies
> How does one view the content of a cookie when it is submitted by the
> client browser?
> Also is there a way of simulating cookie data via the command line?
> 
> Currently I use a combination of print statments and Data::Dumper,
> surely there must be an inbuilt method.
> 
> 2) Template.pm with CGI.pm
> I have recently started using CGI.pm below is a subsection of code
> 
> ----
> $query = new CGI;
> $query->param('file').....
> ....
> my $ttconfig =  {
>                         # allow absolute path statments
>                         ABSOLUTE => 1,
>                 };
> 
> my $tt = Template->new($ttconfig);
> $tt->process('./foo.tt', { centre => $query }) || die $tt->error;
> -------
> 
> in foo.tt i have TT syntax like
> 
> [% centre.file %]
> 
> whenthe program is excuted I get the error
> 
> undef error - Undefined subroutine CGI::failure
>  at (eval 12) line 9
> 
> I am aware that I am referencing the data incorrectly in foo.tt, but I
> am unable to work out the correct method:
> I thought Template.pm could figure out what data type it is passed?
> $query is of   type CGI. Is it because it is not a builtin type
> Template.pm does not know what to do?
> What is the best method to pass CGI info to a template
> 
> what I'm doing now:
> Investigated TT module Template::Plugin::CGI
> added 
> [% USE CGI %]
> get error:
> undef error - Undefined subroutine CGI::failure
>  at (eval 12) line 13
> 
> 
> thank you in advance for any advice.
> K



------------------------------

Date: Thu, 25 Sep 2003 16:39:36 +0100
From: Mr I <konny@waitrose.com>
Subject: Re: 1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm
Message-Id: <tseb41-25q.ln1@sam.amaretti.net>

Frodo Larik wrote:

> Mr I wrote:
> 
>> How does one view the content of a cookie when it is submitted by the
>> client browser?
> 
> 
> I use this:
> 
> sub get_Cookie()
> {
>    my $lookfor = $_[0];
>    my $cookie;
> 
>    if ( defined($ENV{'HTTP_COOKIE'})  )
>    {
>       foreach $cookie ( split (/; /,$ENV{'HTTP_COOKIE'}) )
>       {
>          if ( $cookie =~ /^$lookfor=/ )
>          {
>             my $value = $cookie;
>             $value =~ s/^$lookfor=//;
>             return $value;
>          }
>       }
>    }
>    return "1";
> }
> 
> 
> and i get the content by using the name of the cookie, so if cookie is 
> called 'bla', my $value = &get_Cookie('bla');
> 
Thanks. Once again I have done a similar solution in my code.
But this does not help when in command line mode as i cannot workout how 
to pass cookie info to CGI.pm

Thanks still for your advice...
K



------------------------------

Date: Thu, 25 Sep 2003 18:09:28 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: 1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm
Message-Id: <pan.2003.09.25.10.12.33.29101@aursand.no>

On Thu, 25 Sep 2003 02:29:10 -0700, Mr I wrote:
>> Personally, almost everything related to debugging is "done by" by a Log
>> module I'm using.  In my code I could write:
>> 
>>   my $cookie_value = $cgi->cookie( 'auth_my_site' );
>>   $Log->debug( 'Found cookie: ' . $cookie_value );
>> 
>> On one of my virtual desktops (I'm running Gnome) I have a terminal
>> windows open where i 'tail' Apache's error log.  Voilá! :-)

> Ditto.. just not using log module...

Well.  Why not?  There are a lot of decent Log modules out there.  I use
one I've written myself, though.

As a last resort, you can always use 'print STDERR' combined with a DEBUG
constant in your script.  However, you might want to examine 'caller()'
everytime, which "requires" (practically) an own module for the job.

> surely CGI.pm has an inbuilt method (not directed @perl)

Well.  You can always specify CGI.pm to use the '-debug' flag;

  use CGI qw(:cgi -compile -debug);

Never used it, though.


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: Thu, 25 Sep 2003 18:09:29 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: 1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm
Message-Id: <pan.2003.09.25.10.13.32.910707@aursand.no>

On Thu, 25 Sep 2003 11:15:20 +0200, Frodo Larik wrote:
>> How does one view the content of a cookie when it is submitted by the
>> client browser?

> I use this:
> 
> sub get_Cookie()
> [...]

I am really looking forward to _your_ excuse for not using CGI.pm.


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: Thu, 25 Sep 2003 18:08:37 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: 1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm
Message-Id: <Pine.LNX.4.53.0309251728360.24836@ppepc56.ph.gla.ac.uk>

On Thu, 25 Sep 2003, Mr I wrote:

> But this does not help when in command line mode as i cannot workout how
> to pass cookie info to CGI.pm

Cookies are presented to a CGI script by the CGI interface via the
"environment", specifically HTTP_COOKIE.  So if you want to test input
to your CGI script from the command line, presumably you'd want to set
the corresponding environment variable prior to calling the script
from the command line.

CGI.pm offers a debugging convenience of accepting query parameters
and their values from the command line (or in -debug mode from
standard input) as shown at
http://stein.cshl.org/WWW/software/CGI/#debugging

But cookies are not query parameters, and I'm not aware of any
trickery offered by CGI.pm to get those to your script from the
command line.  I'd say set them up in the environment before you
invoke your script from the command line, if you're sure you want to
debug that way.

There's only a limited amount of useful testing that one can do in
this way, IMHO.  I find it more useful to have a local web server
running, and test CGI scripts from that, and then you have the benefit
of the cookie module on the server side, and your browser on the
client side, to take care of the nitty details of HTTP.

On the other hand if browser or server are misbehaving then you might
want some kind of instrumented proxy between the client and the serve
to tell you what's going on.  You might want to take a look at Nick
Kew's cg-eye.  http://www.htmlhelp.com/tools/cg-eye/

There's very little that's Perl-specific in any of this.  Most of this
discussion would seem to me to be better at home on the group
comp.infosystems.www.authoring.cgi


------------------------------

Date: 25 Sep 2003 06:52:26 -0700
From: indian_spindoctor@yahoo.com (mani)
Subject: A doubt
Message-Id: <1c84265c.0309250552.53dbc5bf@posting.google.com>

Hi,

   I see this code :

while(<STDIN>){

  if(/^From: /){

   if(/merlyn/){
    print "Email from merlyn\n";
 }
last;
}
if(/^$/){

  last;
}
}

what i cant understand is this :

 I know that whatever is read from STDIN is read into $_ I thought if
we are looking for something which has From: we should look for this
pattern in $_
but i am seeing that the $_ never appers in the first if control
statement.
Is it understood that we are refering to $_ everywhere if not
specified in a control statement ???


thanks
\
Mani


------------------------------

Date: Thu, 25 Sep 2003 14:08:51 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A doubt
Message-Id: <TFCcb.3644$FH3.3551@nwrddc02.gnilink.net>

mani wrote:
> while(<STDIN>){
>   if(/^From: /){
[...]
> what i cant understand is this :
>
>  I know that whatever is read from STDIN is read into $_ I thought if
> we are looking for something which has From: we should look for this
> pattern in $_
> but i am seeing that the $_ never appers in the first if control
> statement.
> Is it understood that we are refering to $_ everywhere if not
> specified in a control statement ???

No, that assumption would be wrong. You are refering to $_ if the man page
of the involved function says so.
You just need to understand what functions and operators are involved.

"/^From:/" is the short form of "m(/^From:/)" (sorry, this one you just have
to know).
Now, checking out the documentation of "m" using "perldoc -f m" tells us:

        m//     The match operator. See the perlop manpage.

Ok, let's check the perlop man page, "perldoc perlop":

    m/PATTERN/cgimosx
    /PATTERN/cgimosx
            Searches a string for a pattern match, and in scalar context
            returns true if it succeeds, false if it fails. If no string is
            specified via the "=~" or "!~" operator, the $_ string is
            searched.

>>> There is the answer to your question<<<

            If "/" is the delimiter then the initial "m" is optional.

>>>And there is the explanation for the short form.

jue




------------------------------

Date: Thu, 25 Sep 2003 17:59:35 GMT
From: Lionel Valero <lionel.valero@polymtl.ca>
Subject: Re: Apache session
Message-Id: <b2Gcb.35601$C92.26672@charlie.risq.qc.ca>

CGI:Session will be fine, i do not wear socks anyway.

Lionel Valero wrote:

> Hello,
> 
> I would like to handle http request session, may you give me some useful 
> advices ?
> 
> Regards.

-- 
-=O=------------------------------------------=O=-
Lionel Valéro
Analyste Informatique Département Génie Chimique
École Polytechnique de Montréal
C.P. 6079, succ. centre-ville
Montréal (Québec) H3C 3A7
Tel: (514) 340 - 4711 # 4805 / C552
Fax: (514) 340 - 4159
-=O=------------------------------------------=O=-




------------------------------

Date: Thu, 25 Sep 2003 18:00:23 GMT
From: Lionel Valero <lionel.valero@polymtl.ca>
Subject: Re: Apache session
Message-Id: <X2Gcb.35610$C92.10476@charlie.risq.qc.ca>

I have found the CGI:Session package.

Abigail wrote:

> Lionel Valero (lionel.valero@polymtl.ca) wrote on MMMDCLXXIV September
> MCMXCIII in <URL:news:efIbb.24582$C92.18359@charlie.risq.qc.ca>:
> ==  Hello,
> ==  
> ==  I would like to handle http request session, may you give me some useful advices ?
> 
> 
> Always wear dry socks.
> 
> 
> 
> Abigail

-- 
-=O=------------------------------------------=O=-
Lionel Valéro
Analyste Informatique Département Génie Chimique
École Polytechnique de Montréal
C.P. 6079, succ. centre-ville
Montréal (Québec) H3C 3A7
Tel: (514) 340 - 4711 # 4805 / C552
Fax: (514) 340 - 4159
-=O=------------------------------------------=O=-




------------------------------

Date: 25 Sep 2003 08:50:20 -0700
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Bear trap in scoping rules
Message-Id: <d27434e.0309250750.4c30595e@posting.google.com>

I have a program that calls functions in a module which
I also wrote, and have just wasted two hours chasing a bug
which turned out to be caused by a rogue 'foreach' loop
variable.

I was using a variable exported by the module as the loop
variable of a 'foreach' in the main program, and when a
function in the module was called by the main program,
from within the scope of the foreach, the variable of
the same name in the module had a different value! DUH!?

As soon as I changed the foreach to use a 'my' variable,
everything worked as I had expected.

Just thought I'd mention this strange feature, which seems
to me like a slight flaw (or bug?) in Perl - If variables
in another namespace cannot be used reliably as foreach
loop variables then 'use strict' should warn about this.


Cheers

John Ramsden


------------------------------

Date: Thu, 25 Sep 2003 11:59:49 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: John Ramsden <john_ramsden@sagitta-ps.com>
Subject: Re: Bear trap in scoping rules
Message-Id: <Pine.SGI.3.96.1030925115922.813331A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On 25 Sep 2003, John Ramsden wrote:

>I have a program that calls functions in a module which
>I also wrote, and have just wasted two hours chasing a bug
>which turned out to be caused by a rogue 'foreach' loop
>variable.
>
>I was using a variable exported by the module as the loop
>variable of a 'foreach' in the main program, and when a
>function in the module was called by the main program,
>from within the scope of the foreach, the variable of
>the same name in the module had a different value! DUH!?
>
>As soon as I changed the foreach to use a 'my' variable,
>everything worked as I had expected.

Could you post some code as an example?  What version of Perl are you
using?

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



------------------------------

Date: Thu, 25 Sep 2003 18:03:51 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Bear trap in scoping rules
Message-Id: <jc46nv0d7rfv0q3a8qf9nfighn17047mc6@4ax.com>

X-Ftn-To: John Ramsden 

john_ramsden@sagitta-ps.com (John Ramsden) wrote:
>I was using a variable exported by the module as the loop
>variable of a 'foreach' in the main program, and when a
>function in the module was called by the main program,
>from within the scope of the foreach, the variable of
>the same name in the module had a different value! DUH!?
>
>As soon as I changed the foreach to use a 'my' variable,
>everything worked as I had expected.
>
>Just thought I'd mention this strange feature, which seems
>to me like a slight flaw (or bug?) in Perl - If variables
>in another namespace cannot be used reliably as foreach
>loop variables then 'use strict' should warn about this.

Did you "use strict"?
Can you post relevant code which can reproduce this flaw?



-- 
Matija


------------------------------

Date: 25 Sep 2003 16:43:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Bear trap in scoping rules
Message-Id: <bkv602$oti$1@mamenchi.zrz.TU-Berlin.DE>

John Ramsden <john_ramsden@sagitta-ps.com> wrote in comp.lang.perl.misc:
> I have a program that calls functions in a module which
> I also wrote, and have just wasted two hours chasing a bug
> which turned out to be caused by a rogue 'foreach' loop
> variable.
> 
> I was using a variable exported by the module as the loop
> variable of a 'foreach' in the main program, and when a
> function in the module was called by the main program,
> from within the scope of the foreach, the variable of
> the same name in the module had a different value! DUH!?

Of course.  Exported variables are package variables which are global
by nature.  If you change a global somewhere, you change it everywhere.

If I read this right, you were using a variable exported by the module
as the loop variable of foreach in the main program.  This is an utterly
strange arrangement.  If you do something like this deliberately (it
*could* make sense), you must be aware of the consequences.

If it happened by accident, that means you used a package variable for
the loop variable, which is considered bad programming practice.  You
have just seen why.

The effect you have seen has nothing to do with exportation per se, it
would have shown as well if the variable had been used by a function in
the same file.

> As soon as I changed the foreach to use a 'my' variable,
> everything worked as I had expected.
>
> Just thought I'd mention this strange feature, which seems
> to me like a slight flaw (or bug?) in Perl - If variables
> in another namespace cannot be used reliably as foreach
> loop variables then 'use strict' should warn about this.

Well, "use strict 'vars'" would have warned against the use of an
unqualified package variable.  Only the fact that it was exported, and
hence declared, "saved" you from this warning.  It is assumed that you
are aware when you use an imported variable and know what you are doing.

Two lessons can be learned from this:

- Per default, declare all variables (including loop variables) with "my"
  in the smallest possible scope.

- Exported variables or functions should have distinctive names, so they
  don't easily create name conflicts in the target package.

Anno


------------------------------

Date: Thu, 25 Sep 2003 19:52:57 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: class methods
Message-Id: <pan.2003.09.25.16.22.54.622852@aursand.no>

On Thu, 25 Sep 2003 12:38:29 +0000, Anno Siegel wrote:
>> There is no such thing as "manipulating a whole class", or - as you
>> describe it - impacting a whole class.  You never work with _classes_.
>> You work with objects, which are _instances of classes_.

> What makes you say that?

I didn't, actually.  It was the original poster who used the term
"impacting a whole class".  I took it as he meant "manipulating a whole
class", which is a term I prefer.

> Manipulation of the whole class is quite possible and that's what class
> method calls are for.

I know that, but I still don't consider that as "manipulating a whole
class", whatever that _really_ means. :-)

Your examples of using class methods are all fine, but they still define
the behaviour of the objects of the class (whether they _have been_
created or _will be_ created).

Please see my explanation in the context of the current thread;  Instead
of using __PACKAGE__ to find out who's calling who, one should stick with
the good ol' fashioned OO style in calling methods in other classes.  If
you don't, your design will break as soon as someone subclasses one of the
classes (as an example).

> Class methods are generally much rarer than object methods, but they
> have their place.

Indeed.

> Calling a method as an ordinary sub is something else and should not be
> done, because that would break inheritance.

Hmm.  How many words did I use to say the same? :-)


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: Thu, 25 Sep 2003 16:27:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Compiling perl with GCC
Message-Id: <bkv4po$5td$1@ichaos.ichaos-int>

Marcus <marcus@automint.co.uk> said:
>OK tried changing the -03 in the makefile to -02 and it looked better 

Note, the optimization option is -O2, not -02.

>Thank you, but any more ideas?

Check if there's any later gcc RPM for your distribution. Though what
you have seems pretty recent already.

Note that you can't safely mix&match RPMs from different distributions,
so even through you might be succesful in installing an RPM meant
for some other distribution, there's no guarantee it'll work properly.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


------------------------------

Date: Thu, 25 Sep 2003 17:29:09 +0100
From: "Paul Tomlinson" <rubberducky703@hotmail.com>
Subject: Easy way to replace 0 with empty string?
Message-Id: <bkv54o$6g4oh$1@ID-116287.news.uni-berlin.de>

Is there an easy one line way to replace a 0 with empty string?

PT




------------------------------

Date: Thu, 25 Sep 2003 16:33:32 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: Easy way to replace 0 with empty string?
Message-Id: <slrnbn666q.mk3.ak+usenet@otaku.freeshell.org>

In article <bkv54o$6g4oh$1@ID-116287.news.uni-berlin.de>, Paul Tomlinson wrote:
> Is there an easy one line way to replace a 0 with empty string?

Do you need anything more sofisticated than "s/0//"?


$ perl -e '$a=10; $a =~ s/0//;print $a, "\n"'
1



-- 
Andreas Kähäri


------------------------------

Date: Thu, 25 Sep 2003 16:45:39 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Easy way to replace 0 with empty string?
Message-Id: <Xns940181BCF81BFdkwwashere@216.168.3.30>

Andreas Kahari <ak+usenet@freeshell.org> wrote:

> In article <bkv54o$6g4oh$1@ID-116287.news.uni-berlin.de>, Paul
> Tomlinson wrote: 
>> Is there an easy one line way to replace a 0 with empty string?
> 
> Do you need anything more sofisticated than "s/0//"?
> 
> 
> $ perl -e '$a=10; $a =~ s/0//;print $a, "\n"'
> 1

If it's just a single character I'd use 'tr/0//d'.

I'm not entirely sure what is meant by "empty string".  It might 
possibly mean replacing '0' with a space: 'tr/0/ /'.

-- 
David Wall


------------------------------

Date: 25 Sep 2003 16:49:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Easy way to replace 0 with empty string?
Message-Id: <bkv6am$oti$2@mamenchi.zrz.TU-Berlin.DE>

Andreas Kahari  <ak+usenet@freeshell.org> wrote in comp.lang.perl.misc:
> In article <bkv54o$6g4oh$1@ID-116287.news.uni-berlin.de>, Paul Tomlinson wrote:
> > Is there an easy one line way to replace a 0 with empty string?
> 
> Do you need anything more sofisticated than "s/0//"?
> 
> 
> $ perl -e '$a=10; $a =~ s/0//;print $a, "\n"'
> 1

The OP has under-specified his problem.  What he wants may also be the
common idiom "$x ||= ''".  It replaces 0 (and undef) with an empty string.

Anno


------------------------------

Date: Thu, 25 Sep 2003 16:51:43 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Easy way to replace 0 with empty string?
Message-Id: <z2Fcb.3989$kD3.2454@nwrdny03.gnilink.net>

Paul Tomlinson <rubberducky703@hotmail.com> wrote:
> Is there an easy one line way to replace a 0 with empty string?

  $input =~ tr/0//d;

-- 
Steve


------------------------------

Date: Thu, 25 Sep 2003 18:51:30 +0200
From: John Bokma <postmaster@castleamber.com.invalid>
Subject: Re: Easy way to replace 0 with empty string?
Message-Id: <1064508817.579704@halkan.kabelfoon.nl>

Paul Tomlinson wrote:

> Is there an easy one line way to replace a 0 with empty string?

In what context? Removing leading zeroes?

-- 
Kind regards,       virtual home: http://johnbokma.com/  ICQ: 218175426
                     web site hints: http://johnbokma.com/websitedesign/
John       I count my toes ~ one to ten ~ I meditate ~ and feel the Zen



------------------------------

Date: Thu, 25 Sep 2003 17:03:39 +0200
From: Andreas Moroder <amoroder@sb-brixen.[nospam]it>
Subject: getcwd or similar
Message-Id: <bkv0bo$vd4$1@news.flashnet.it>

Hello if I start a perl script with a relative path e.g 
mydir/myscirpt.pl while I am in opt then getcwd return the path /opt

Is there a way in perl to get the directory where the script really is 
(opt/mydir ) ?

Thanks
Andreas



------------------------------

Date: Thu, 25 Sep 2003 15:24:03 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: getcwd or similar
Message-Id: <nMDcb.11662$ZR1.8491@nwrddc01.gnilink.net>

Andreas Moroder wrote:
> Hello if I start a perl script with a relative path e.g
> mydir/myscirpt.pl while I am in opt then getcwd return the path /opt
>
> Is there a way in perl to get the directory where the script really is
> (opt/mydir ) ?

What do you mean by "directory where the script really is"?

The location in the directory tree where the script can be found?
perdoc -q directory
      "How do I add the directory my program lives in to the module/library
search path?"

Your current working directory?
perldoc Cwd

Something totally different?
Please explain.

jue




------------------------------

Date: Thu, 25 Sep 2003 15:26:27 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: getcwd or similar
Message-Id: <slrnbn6291.mk3.ak+usenet@otaku.freeshell.org>

In article <bkv0bo$vd4$1@news.flashnet.it>, Andreas Moroder wrote:
> Is there a way in perl to get the directory where the script really is 
> (opt/mydir ) ?


See the FindBin module.


-- 
Andreas Kähäri


------------------------------

Date: Thu, 25 Sep 2003 15:37:08 +0000 (UTC)
From: "D Borland" <no.name@eidosnet.co.uk>
Subject: Re: getcwd or similar
Message-Id: <bkv234$pve$1@hercules.btinternet.com>

"Andreas Moroder" <amoroder@sb-brixen.[nospam]it> wrote in message
news:bkv0bo$vd4$1@news.flashnet.it...
> Hello if I start a perl script with a relative path e.g
> mydir/myscirpt.pl while I am in opt then getcwd return the path /opt
>
> Is there a way in perl to get the directory where the script really is
> (opt/mydir ) ?
>
> Thanks
> Andreas
>

I think you can use FindBin for this,

use FindBin '$Bin';

print "$Bin\n";           # prints directory where script is located

Dagmar


---
This e-mail has been virus scanned and is certified virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/24/03




------------------------------

Date: Thu, 25 Sep 2003 16:27:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: getcwd or similar
Message-Id: <bkv4v5$5td$2@ichaos.ichaos-int>

Andreas Moroder <amoroder@sb-brixen.[nospam]it> said:
>Hello if I start a perl script with a relative path e.g 
>mydir/myscirpt.pl while I am in opt then getcwd return the path /opt
>
>Is there a way in perl to get the directory where the script really is 
>(opt/mydir ) ?

Mostly you should be able to use the FindBin, as has been suggested by
others. However, it is possible for another program to execute your program
in such a way that you don't get any (or that you will get misleading)
information about where the program is located.

If you asked this to be able to place a configuration file to the same
directory with the program, please rething your design, and place the
configuration file in some sensible location.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


------------------------------

Date: Thu, 25 Sep 2003 15:40:48 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: How to go up trace stack in debugger?
Message-Id: <bkv2a0$ga9$1@reader2.panix.com>




Here's a recurrent situation.  I'm running a program in the debugger,
the program dies for some reason, and I want to inspect the scope
in which the current function was called.  In other words, I want
to be able to climb up the stack trace and poke around there.  How
can I do this?

Thanks!

	-Jill


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5561
***************************************


home help back first fref pref prev next nref lref last post