freddo411 has asked for the wisdom of the Perl Monks concerning the following question:
I'm using Class::DBI. I have the following syntax which won't work (in Perl 5.005) and I'm wondering how it can be done:
use strict; use warnings; ...snip... my $nn = "admin_contact_fk" ; my $foo = $record->$nn; perl -c CDNR.pm syntax error at CDNR.pm line 293, near "$nn;" BEGIN not safe after errors--compilation aborted at CDNR.pm line 466.
Doesn't work... but...
my $foo = $record->admin_contact_fk;
Does work.
Can someone explain how to use a variable with the "->" operator?
UPDATE: changed subject to include perl version
Please don't tell me to upgrade, as I don't control the production environment at my $firm.
-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Syntax question (Perl 5.005)...
by chromatic (Archbishop) on Nov 07, 2003 at 22:10 UTC | |
|
Re: Syntax question...
by hardburn (Abbot) on Nov 07, 2003 at 21:34 UTC | |
by freddo411 (Chaplain) on Nov 07, 2003 at 22:01 UTC |