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

Re: Help creating a function

by samarzone (Pilgrim)
on Feb 16, 2011 at 07:25 UTC ( #888455=note: print w/ replies, xml ) Need Help??


in reply to Help creating a function

Are you working on Perl? Above code snipped will not compile in Perl 5.

bless or eval may be of interest for you. If the data structure passed in arguemnts(e.g. $employeeData) has exactly the same structure as of the underlying object of the given package, you can directly bless it. If not, you'll have to first create some rules to set the properties of object from given data structure and then "eval"

The cost of genericness may be that you know the underlying structure of package and pass the correct arguments.

--
Regards
- Samar


Comment on Re: Help creating a function
Select or Download Code
Re^2: Help creating a function
by varghees (Novice) on Feb 16, 2011 at 08:03 UTC
    yeah I know it will not compile in perl. I just used pseudo code in that example. Second parameter can have more values also. It can have some values like $employeeData=>{create} like that. Also I want the return object should be the type of first argument.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2014-07-31 20:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (253 votes), past polls