Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Variable Substitution within NameSpace

by ccn (Vicar)
on Aug 04, 2004 at 08:06 UTC ( [id://379929]=note: print w/replies, xml ) Need Help??


in reply to Variable Substitution within NameSpace

$xx="custtype"; print "$R::$xx" ; ## but this prints only "custtype"???
Can anybody tell me what syntax I should use for this to work?

You can do exactly what you want, but it is not a good way for CGI applications.

$xx="custtype"; print eval "\$R::$xx"; $erxx = eval "\$R::$xx"; print "R::xx = $errxx\n";

Replies are listed 'Best First'.
Re^2: Variable Substitution within NameSpace
by yellow_tree_frog (Initiate) on Aug 04, 2004 at 17:43 UTC
    i should have specified i'm working on Windows 2000.
    ccn's solution below worked:
    print eval "\$R::$xx";
    but the soln by SUNADM below only printed ::custtype. Maybe this would have worked on a Unix based OS.

    print "$R" . "::" . "$xx\n";

    I will though take the advice of avoiding using symbolic references in this manner and instead will use the CGI param method.
    Thanks for all the help. ytf

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-03-28 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found