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