Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Issue with env variables set through dos batch

by Anonymous Monk
on Nov 06, 2012 at 06:25 UTC ( [id://1002416]=note: print w/replies, xml ) Need Help??


in reply to Re: Issue with env variables set through dos batch
in thread Issue with env variables set through dos batch

what will happen in case batch file have values like : %VAL%=<some path>:%VAL% i you read it as a key value pair, then the values that get appended are lost
  • Comment on Re^2: Issue with env variables set through dos batch

Replies are listed 'Best First'.
Re^3: Issue with env variables set through dos batch
by Anonymous Monk on Nov 06, 2012 at 09:37 UTC

    what will happen in case...

    It should take all of 10 seconds to find out :) Try It To See

Re^3: Issue with env variables set through dos batch
by Athanasius (Archbishop) on Nov 06, 2012 at 07:12 UTC
    i[f] you read it as a key value pair, then the values that get appended are lost

    Not at all. The code line:

    my ($k, $v) = split /=/, $_, 2;

    splits each data line into two parts: the part to the left of the first = character — which is assigned to $k — and the entire part to the right of the first = character — which is assigned to $v. So nothing is lost. In your example, the batch file would contain:

    set VAL=<some path>:%VAL%

    and if VAL already contained, say, /bin, the result would be the assignment of VAL to $k and of <some path>:/bin to $v. See split:

    If LIMIT is specified and positive, it represents the maximum number of fields into which the EXPR may be split; in other words, LIMIT is one greater than the maximum number of times EXPR may be split.

    Hope that helps,

    Athanasius <°(((><contra mundum

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1002416]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found