home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!sgiblab!daver!zorch!tandem!Tandem.com!sylvia
- From: sylvia@Tandem.com (Sylvia Tom)
- Newsgroups: comp.lang.perl
- Subject: usersub problems when invoked within a subroutine
- Message-ID: <1992Sep11.201054.1512@tandem.com>
- Date: 11 Sep 92 20:10:54 GMT
- Sender: news@tandem.com
- Organization: Tandem Computers
- Lines: 50
- Nntp-Posting-Host: moe.cpd.tandem.com
-
- Keywords: usersub
-
- Thanks for posting the notes on how to hook in usubs.
- I've compiled ex1.c on a sun workstation and found
- the following problem. If I call opie from within
- a subroutine and the subroutine returns a list,
- the resulting information returned is lost. If,
- I put parenthesis around $new in the call to opie,
- eg ($new) = &opie($num), the script runs as
- expected. Do you know why this is behaving this way?
-
- Thanks,
- sylvia
- sylvia@tandem.com
-
-
- sub getval
- {
- local ($num) = @_;
- print "number entered is $num \n";
- $new =&opie($num);
- print "new = $new \n";
- local ($buf) = "hi there ";
- local($res) = 1;
- return ($new,$buf,$res);
- } #===============================================
- if ( defined(&opie) ) {
- print "&opie is defined\n";
- print "\t&opie(10) = ", &opie(10), "\n";
- } else {
- print "&opie is not defined\n";
- }
-
-
- ($val,$buffer,$result) = &getval (5);
- print "val = $val \n";
- print "buffer = $buffer \n";
- print "result = $result \n";
- #===================================================
-
- #resulting output ->
-
- &opie is defined
- &opie(10) = 101.20000000000000284
- number entered is 5
- new = 26.199999999999999289
- val = 1
- buffer =
- result =
-
-