home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 5059 < prev    next >
Encoding:
Text File  |  1992-07-31  |  1.6 KB  |  45 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!s5!is1.is.morgan.com!is0.is.morgan.com!robt
  3. From: robt@is.morgan.com (Rob Torop)
  4. Subject: usersub advice requested
  5. Message-ID: <ROBT.92Jul31123901@idt101.is.morgan.com>
  6. Sender: news@is.morgan.com
  7. Nntp-Posting-Host: idt101
  8. Organization: Morgan Stanley & Company
  9. Distribution: comp.lang.perl
  10. Date: Fri, 31 Jul 1992 17:39:01 GMT
  11. Lines: 32
  12.  
  13. I've been home sick and have finally gotten around to trying to
  14. understand usub and related mysteries. I've gotten pretty far, but the
  15. following has been stumping me for two days now.  Any advice?  Once I
  16. understand enough, I will write up an idiot proof tutorial on usersub
  17. and post it.
  18.  
  19. Suppose I want to hook in a function to perl and call it like this:
  20.  
  21.     $s{'blah'} = 12;
  22.     $s{'bleh'} = 13;
  23.     ...
  24.     $x = &myfn(*s, 100);
  25.  
  26. How do I pull the value associated with 'blah' out of st[1] in my
  27. usersub?  I can't figure out how this works, but I'm betting that it's
  28. just a simple function call to a hash table lookup function, passing
  29. something like st[1]->str_u->str_hash and "blah". 
  30.  
  31. And should I pass back associative arrays just like regular arrays,
  32. just interleaving the keys and values, eg ('andy', 1, 'opie', 2,
  33. 'floyd', 3)?
  34.  
  35. I know I could write myfn as a cover to another perl function that
  36. takes a million parameters and call it like &myfun_aux($s{'blah'},
  37. $s{'bleh'}, ...) but that's no fun at all.
  38.  
  39. --
  40. -- Rob Torop
  41.  
  42. +---------------------------------------------------------------------+
  43. | The views expressed here are neither mine nor those of my employer. |
  44. +---------------------------------------------------------------------+
  45.