Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?


by smitz (Chaplain)
on Sep 09, 2003 at 13:30 UTC ( #290029=note: print w/replies, xml ) Need Help??

in reply to

Your first code snippet contains
my $node; if ($node eq...
Is this a typo? $node will always eq undef in this case. Did you mean
my $node = param('node')
You could do it something like this: (untested code):
#!/usr/bin/perl use CGI; my $node = param('node'); my %lookup_table = (how => 'how_sub', foo => 'foo_sub'); if ($lookup_table{$node} ne '') { &{$lookup_table{$node}}; } else { print "Unknown sub called\n"; } sub how_sub {} sub foo_sub {}
The %lookup_table and if routine makes sure users cant choose any old sub to run,
just the ones you define in the lookup_table.


Replies are listed 'Best First'.
Re: Re:
by surrealistfashion (Acolyte) on Sep 10, 2003 at 03:08 UTC
    I was under the impression that having it $node undef was ok, if I declared it in the Url.
    I will try the lookup_table when I am off work tonight.
    With your code does the param('node') come from the Url?
    I have more reading to do :D
      Hi surrealistfashion,

      Yes you do have some more reading to do :-) Check out the following:

      Although you have the sub name in your URI, and the module has access to it, you have not 'imported' it into your program.
      Just by declaring it with my doesn't automatically give it the value you woul like. This isn't PHP you know ;-)
      Also, I ran the code I posted, it should work fine.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2022-08-09 00:59 GMT
Find Nodes?
    Voting Booth?

    No recent polls found