RE: Aliases in Perl?
"Bakken, Luke" <[EMAIL PROTECTED]> wrote: > > Hi, > > > > Are there 'aliases' in perl? For example, if I have a Korn > > shell script and > > a function named "increaseCost()", I can do this: "alias > > decreaseCose=increaseCost" (passing a parameter in). of > > course this is a > > simplified example of what I want to do, but the point is to make it > > self-documenting. > > > > Maybe what I need is a "reference" ? > > Personally, I've never (directly) used this feature, but here it is: > > use strict; > > sub foo > { > print "Called foo\n"; > } > > *bar = \&foo; > > foo(); > > bar(); Exactly what I am looking for! THANKS!!! -Jeff __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Aliases in Perl?
Jeff Westman wrote: > > Are there 'aliases' in perl? For example, if I have a Korn shell script and > a function named "increaseCost()", I can do this: "alias > decreaseCose=increaseCost" (passing a parameter in). of course this is a > simplified example of what I want to do, but the point is to make it > self-documenting. > > Maybe what I need is a "reference" ? I'm not clear what you want to do Jeff. Is it something like this? my $cost; sub increaseCost { my $delta = shift; $cost += $delta; } sub decreaseCost { my $delta = shift; increaseCost(-$delta); } In which case you should write it exactly this way and forget about aliases. If I'm guessing wrongly then let us know. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Aliases in Perl?
> Hi, > > Are there 'aliases' in perl? For example, if I have a Korn > shell script and > a function named "increaseCost()", I can do this: "alias > decreaseCose=increaseCost" (passing a parameter in). of > course this is a > simplified example of what I want to do, but the point is to make it > self-documenting. > > Maybe what I need is a "reference" ? Personally, I've never (directly) used this feature, but here it is: use strict; sub foo { print "Called foo\n"; } *bar = \&foo; foo(); bar(); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Aliases in Perl?
> Hi, > > Are there 'aliases' in perl? For example, if I have a Korn shell script and > a function named "increaseCost()", I can do this: "alias > decreaseCose=increaseCost" (passing a parameter in). of course this is a > simplified example of what I want to do, but the point is to make > it > self-documenting. > Maybe what I need is a "reference" ? Indeed it is. Such as: my $increaseCost_ref = \&increaseCost; To call it: $increaseCost_ref->($some_arg); Cheers! This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Aliases in Perl?
Hi, Are there 'aliases' in perl? For example, if I have a Korn shell script and a function named "increaseCost()", I can do this: "alias decreaseCose=increaseCost" (passing a parameter in). of course this is a simplified example of what I want to do, but the point is to make it self-documenting. Maybe what I need is a "reference" ? TIA Jeff __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]