Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: variable sub function?

by chromatic (Archbishop)
on May 30, 2002 at 14:40 UTC ( #170398=note: print w/ replies, xml ) Need Help??


in reply to variable sub function?

A general rule of programming: if you want to store a number of distinct things, use an aggregate data type. A general rule of Perl programming: if you want to store several things and access them by name, use a hash.

Use a hash of subroutine references.

(As side notes, matching equality of a simple integer with a regular expression is, at best over kill. Assigning a single element to a list slice is, until Perl 6, deprecated. Incrementing $count to add elements to an array is usually better spelled push.)

Update: Okay, my analysis ignores the realities of Win32::GUI. Disturbing.


Comment on Re: variable sub function?
Re: Re: variable sub function?
by c-era (Curate) on May 30, 2002 at 14:54 UTC
    The problem here is that he is using Win32::GUI components. Win32::GUI has some strangaties. If you want to catch events, you need a sub for each event on each object. For example if you have an object named x and want to catch a change event, you will need to have a sub called x_Change. If you create another object called y, you will now need to create a sub called y_Change to catch change events for y. Unlike most GUI implementations, you can't register a sub for an event, the sub names are hard coded for each object.

    This was one of the many reasons I stopped using Win32::GUI.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://170398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-11-24 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (135 votes), past polls