Nalina has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I am calling perl from snmx as shown.
perl C:\msgbox.pl
msgbox.pl contains the following code.
use Win32; $caption = "asg report"; $val = Win32::MsgBox("data for 22nd not found.\n Do u want to continue +?", 4, $caption);
Now I want to pass $val to snmx script back. I tried
return($val)
but got an error
Can't return outside a subroutine at C:\msgbox.pl line 5.
how do I pass parameter from perl script msgbox.pl to snmx which has called msgbox.pl.

Thanks in advance

Replies are listed 'Best First'.
Re: Passing parameters from perl to snmx
by jbrugger (Parson) on Mar 16, 2005 at 07:32 UTC
    Seems nothing wrong with the perl code... Can you give some more info about snmx?
    I've never heard of it, and google wasn't verry communicative:
    Simple Network Management Executive. SNMX is an executable program and scripting language providing network management functions using SNMP protocol. The SNMX program has application in system administration of networks, network process control, data logging, and interprocess/internetwork communication. It is Freely Distributed to individuals and organizations (with some limitations applying.)
    , but i still would not know how the program is called, or how snmx works.
    *** Update ***
    One thing (little issue in your code), a return value is given from a sub, so in this case you should write: (Have you tried to use STDOUT?)
    use Win32; sub message() { $caption = "asg report"; $val = Win32::MsgBox("data for 22nd not found.\n Do u want to cont +inue?", 4, $caption); return ($val); } print message();
      SNMX scripting language is used in ASG. Its calling Perl script msgbox.pl & then trying to manipulate the variable paased by perl as shown.
      perl C:\msgbox.pl set $tmp = $arg.1 echo $tmp
      When snmx calls a perl script, the control goes to the perl script, executes it & then comes back to the SNMX. This is similar to calling a subroutine, assuming perl script as a subroutine. Now the problem is that the perl script is not able to pass parameter to the SNMX script which has called it.
Re: Passing parameters from perl to snmx
by PodMaster (Abbot) on Mar 16, 2005 at 08:13 UTC
    If look through perlfunc, you can find exit listed alongside return ...
    Keywords related to the control flow of your perl program
    caller, continue, die, do, dump, eval, exit, goto, last, next, redo, return, sub, wantarray

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.