Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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

Comment on Re: Help creating a function
Select or Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2015-11-30 22:15 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (786 votes), past polls