Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.

- Samar

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://888455]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-05-24 21:58 GMT
Find Nodes?
    Voting Booth?