Passing hash to another script via commandline

J

Jürgen Exner

Actually I agree with Purl Gurl. The OP did in fact ask how to pass those
paramaters which he named explicitely.

However I believe the solutions offered so far stop half way. After all, we
do know already which parameters to pass (the OP named then explicitely),
therefore it is just as well to just hardcode them in the callee, i.e. in
interface.pl.

Just add
my %data = (
field1 => 'f1val',
field2 => 'f2val'
);
my($dataref) = \%data;
to interface.pl and now $dataref is a reference to a hash containing exactly
the desired data as specified by the OP.
Much easier, no messy data passing, no IPC, ...

jue
 
I

IanW

I can't speak for the OP, but I bet the OP thought "thank you for the
reminder". Or after a few minutes of "why doesn't this work", said the
same.

well, the keys/values in the hash in the original post were just an example
to make the explanation simple and clear. However, the data in the real hash
could have been anything, including spaces and any type of character. It
seems like I should have mentioned that in my original post. I kinda just
assumed that by asking "how do I pass a hash to another script via the
command line", that any answers would be to that rather than getting too
specific on the example code.

Anyway, thanks for all the replies. I have it working nicely by doing:

$ARGV[0] = \%data;
do 'z:/interface.pl';

as Gunnar suggested :)

Regards
Ian
 
J

Jürgen Exner

IanW said:
well, the keys/values in the hash in the original post were just an
example to make the explanation simple and clear. However, the data
in the real hash could have been anything, including spaces and any
type of character.

Sorry, I appologize if my comment to PurlGurl's rantings were missleading.
Unfortunately I don't know of any emoticon to express sarcasm.
I sure hope you didn't take them literally.
It seems like I should have mentioned that in my
original post. I kinda just assumed that by asking "how do I pass a
hash to another script via the command line", that any answers would
be to that rather than getting too specific on the example code.

As would any sensible person. Unfortunately now you will be hearing PurlGurl
screaming your ear off for changing the requirements...

jue
 
I

IanW

Sorry, I appologize if my comment to PurlGurl's rantings were missleading.
Unfortunately I don't know of any emoticon to express sarcasm.
I sure hope you didn't take them literally.

oh I see.. hehe, no worries :)
As would any sensible person. Unfortunately now you will be hearing
PurlGurl screaming your ear off for changing the requirements...

oh well, I like feisty women ;-) (I think a winky is usually used to
denote sarcasm)

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top