Professional Web Applications Themes

Aliases in Perl? - PERL Beginners

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-doenting. Maybe what I need is a "reference" ? TIA Jeff __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search [url]http://shopping.[/url]...

  1. #1

    Default 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-doenting.

    Maybe what I need is a "reference" ?

    TIA

    Jeff

    __________________________________
    Do you Yahoo!?
    The New Yahoo! Shopping - with improved product search
    [url]http://shopping.[/url]
    Jeff Westman Guest

  2. #2

    Default 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-doenting.
    > 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
    [url]http://www.messagelabs.com[/url]
    __________________________________________________ ______________________
    Stephen Hardisty Guest

  3. #3

    Default 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-doenting.
    >
    > 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();
    Luke Bakken Guest

  4. #4

    Default 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-doenting.
    >
    > 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


    Rob Dixon Guest

  5. #5

    Default RE: Aliases in Perl?

    "Bakken, Luke" <Luke.Bakkengetronics.com> 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-doenting.
    > >
    > > 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
    [url]http://shopping.[/url]
    Jeff Westman Guest

Similar Threads

  1. re-using aliases in SELECT
    By Bart Friederichs in forum MySQL
    Replies: 4
    Last Post: December 8th, 12:38 PM
  2. CFInclude and aliases
    By Tim_Mar in forum Macromedia ColdFusion
    Replies: 0
    Last Post: April 26th, 03:55 PM
  3. RFC: field::aliases
    By Kevin Michael Vail in forum PERL Modules
    Replies: 2
    Last Post: September 28th, 01:24 AM
  4. perl and qmail aliases
    By Andrew Gaffney in forum PERL Beginners
    Replies: 2
    Last Post: December 9th, 03:40 PM
  5. IP-Addresses and aliases
    By Friedhelm Neyer in forum AIX
    Replies: 3
    Last Post: August 6th, 03:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139