RE: Calling functions using variable (I mean symbolic refs)
From: Kamal Gupta (kamal.gupta_at_wipro.com)
Date: 11/26/04
- Next message: Oliver Schnarchendorf: "Re: Perl cant add up with sprintf ?"
- Previous message: Oliver Schnarchendorf: "Re: Perl cant add up with sprintf ?"
- Maybe in reply to: Kamal Gupta: "Calling functions using variable (I mean symbolic refs)"
- Next in thread: Charles K. Clarkson: "RE: Calling functions using variable (I mean symbolic refs)"
- Reply: Charles K. Clarkson: "RE: Calling functions using variable (I mean symbolic refs)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 26 Nov 2004 13:08:31 +0530 To: <kamal.gupta@wipro.com>, <beginners@perl.org>
Some one please do help me....
I'm sure that there could be better solution and I'm sure that someone
would have faced a similar situation.
Do let me know your best possible solution for this scenario.
>Subject: Calling functions using variable (I mean symbolic refs)
>
>
>
>Hi all,
>
>
>May be this is a OLD topic of discussion.
>
>
>I have a Perl script with lot of functions. This Perl script
>accepts two
>command line options (string values) where the concatenation of these
>two strings will give me the function name.
>
>
>All the functions in this Perl script are like this.
>
>
>For eg.,
>
>
>#!/usr/bin/perl
>
>
>use strict;
>
>
>use Getopt::Long;
>
>my $rc = GetOptions( "class|c=s"
> ,"method|m=s"
> ,"help|h|?"
> ,"trace:i"
> );
>...
>..
>..
>...
>{
>no strict 'refs';
>my $functionname = $options{class}."_".$options{method};
>
>
>&$functionname;
>}
>
>
>sub Class1_Method1 {
>
>
>print "Class 1 Method1\n";
>
>
>}
>
>
>sub Class1_Method2 {
>
>
>print "Class 1 Method2\n";
>
>
>}
>
>
>sub Class2_Method1 {
>
>
>print "Class 2 Method1\n";
>
>
>}
>
>
>My question now is in many docs that I have read they say that it is
>always better to avoid symbolic references. Is there any better way of
>implementing the above mentioned scenario, If so do suggest
>and explain.
>
>
>With Best regards,
>R. Kamal Raj Guptha.
>Ph: 91-80-28411990 Ext:1296
>Mobile - 9880351218
>
>
>
>
>
>
>Confidentiality Notice
>
>
>The information contained in this electronic message and any
>attachments to this message are intended
>for the exclusive use of the addressee(s) and may contain
>confidential or privileged information. If
>you are not the intended recipient, please notify the sender
>at Wipro or Mailadmin@wipro.com immediately
>and destroy all copies of this message and any attachments.
>
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
- Next message: Oliver Schnarchendorf: "Re: Perl cant add up with sprintf ?"
- Previous message: Oliver Schnarchendorf: "Re: Perl cant add up with sprintf ?"
- Maybe in reply to: Kamal Gupta: "Calling functions using variable (I mean symbolic refs)"
- Next in thread: Charles K. Clarkson: "RE: Calling functions using variable (I mean symbolic refs)"
- Reply: Charles K. Clarkson: "RE: Calling functions using variable (I mean symbolic refs)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|