Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: confused path

by skyworld_chen (Acolyte)
on Oct 10, 2012 at 06:39 UTC ( #998150=note: print w/replies, xml ) Need Help??


in reply to Re: confused path
in thread confused path

hi,

thanks for reply. Let me explain what happened in detail: I need to transfer a simulation package from one internal network to another internal network in company. Though both networks use linux, there are some differences between them, such as tools setting etc.

here is a piece of code from one script (I did some substitution to make things simple):

(1) use FindBin; (2) use lib $FindBin::Bin; (3) use dbPrjPath; ## company internal package (4) my $dir = dbPrjPath::prjPath(); #find project path (5) my $prog = $FindBin::Script; (6) exec("$prog @ARGV");

above is the code. suppose code above is prog1. In line (4) a new project path is got. In this new project path there is a same script named prog1. The total code will get new project path and run the script in that path with the same script name "prog1" as line (6) indicates, i.e, runs B/prog1. This works well in original system, but in the other system, code in line (6) always runs A/prog1 so it is a infinite loop, which is a strange thing to me.

In order to trace it, I insert a code as this between line (5) and (6) as (5.5) system("which $prog") and it shows B/prog1. I then inserted some debug info to make sure exec("$prog") runs itself. This confused me. so What happened? I confused...

Replies are listed 'Best First'.
Re^3: confused path
by parv (Priest) on Oct 10, 2012 at 07:13 UTC

    Could you reformat your post so that (long) code snippets do not mix with rest of the text? As it is, it is hard to make sense (of code). In case you missed the formatting tips mentioned before the textarea ...

    Use: <p> text here (a paragraph) </p> and: <code> code here </code> to format your post; it's "PerlMonks-approved HTML":
      thanks for your kind remind.
Re^3: confused path
by Anonymous Monk on Oct 11, 2012 at 04:14 UTC

    Please post the values of $dir & $prog. Given those values, tell us where the command to be executed lives.

    (Nonetheless I will venture into mind reading) By the clue of $Script - basename of script ..., try executing the command with path prefixed as in ...

    ... $prog = join '/' , $dir , $prog; exec( $prog , ... );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998150]
help
Chatterbox?
[choroba]: Unfortunately, none of it is online
[haukex]: I figured that POD tests make sense, but only as author tests
[choroba]: I mean, the slides are, but not the makefile with scripts to create them
[Corion]: haukex: I've only now arrived at that revelation ;)
[Corion]: choroba: I use spod5, which also has that support, and also implements its own kinda-make stuff
[haukex]: But that module I just linked to assumes that most verbatim blocks are runnable code, I have other modules where that's not the case, so there I just copy-and-paste the synopsis into the author tests...
[haukex]: not the most efficient, but then again, I don't have that many modules on CPAN :-)
[Corion]: haukex: Yes, but if it's only supposed to run on my machine, I can be far more liberal with how I extract the code etc.
[Corion]: haukex: Yes - I see the benefit of using Dist::Zilla for people with 150+ modules on CPAN, but I don't see it for myself, and I'm always put off from contributing to such modules because they require a lot of toolchain setup that I don't want to ...
[Corion]: ... spend time on if I only want to provide a short patch

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2017-02-27 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (385 votes). Check out past polls.