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

Re: Syntax question when using Class::DBI

by broquaint (Abbot)
on Dec 09, 2004 at 01:13 UTC ( #413393=note: print w/replies, xml ) Need Help??

in reply to Syntax question when using Class::DBI

There is no problem with using a simple scalar variable when dynamically calling a method, as Fletch illustrated. However if you're using an aggregate variable or an expression you can simply use the can method e.g
print $rowobj->can( $cols{id} )->();
Or if you wish to call it directly you need to be a little indirect and take advantage of scalar dereferencing e.g
print $rowobj->${ \$cols{id} };
Addendum: On a more practical note you can always access the primary key by using the id accessor method, regardless of what is the name of the actual row; as documented.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://413393]
[ozboomer]: Howdy, all.. Trying this once more... Not really a perl question :(... but I don't know how to even title my query (more...)
[ozboomer]: There's a text file with lots of sections in it, like an '.ini/.conf' file. Each section can be 'used' or 'unused' by its application (more...)
[ozboomer]: Some folk want to use the text file as 'storage', keeping ALL items in it (a database); others call it an 'active document' that should only contain 'in-use' sections. Is there a 'good practice' for this sort of thing?

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-05-21 00:26 GMT
Find Nodes?
    Voting Booth?