This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Passing arguments to a perl script

Old posts that have not been replied to for several years.
Locked
S
SnowWolf

Passing arguments to a perl script

Post by SnowWolf »

Since TCL couldn't do what I wanted (blasphemy, I know), I made a perl script to do the grunt work... but I'm running into a problem... assuming that $args contains a list of argmunents like {-a 3 -b 4 -c 6}, then I do the following:

set output [exec something.pl $args]

then the perl program is passed one long argument... not seperated ones.
I've tried using 'list', 'join', 'concat', and a few others, but I can't get it right.. even when I use 'join', it seems to escape the spaces to make it one long string.

Can something help point out the (un)obvious answer to this?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Code: Select all

eval exec blah $args
Have you ever read "The Manual"?
S
SnowWolf

Post by SnowWolf »

ayup... that works well enough. *places dunce cap on head and sits in corner*
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

SnowWolf wrote:ayup... that works well enough. *places dunce cap on head and sits in corner*
no need for that cap...it's not that obvious :)

eval is dangerous if you dont know what you're doing. You need an extra layer of escaping for parts that are meant to be passed on without substitutions. I guess I should have pointed this out in the first place...

Code: Select all

set fileName {[die].now}
eval exec $fileName $args
# ...will invoke 'die'
eval [list exec $fileName] $args
# ...will do the right thing because the brackets are escaped by 'list'
Have you ever read "The Manual"?
Locked