in reply to Calling different methods based on a CGI parameter
#!/usr/bin/perl use strict; use warnings; sub sa { print "sub sa\n"; } sub sb { print "sub sb\n"; } my $name = 'a'; # using the symbol table $main::{'s' . $name}->(); $name = 'b'; # using symbolic references: no strict 'refs'; &{"s$name"}();
Be aware that this might open some security holes depending on your application. You have been warned!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Calling different methods based on a CGI parameter
by ysth (Canon) on May 21, 2008 at 18:11 UTC |