Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Programming > Libraries

    ex::override 1.1

    Download button

    No screenshots available
    Downloads: 626  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Casey West | More programs
    Perl Artistic License / FREE
    May 15th, 2007, 04:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    ex::override description

    ex::override is a Perl pragma to override core functions.

    ex::override is a Perl pragma to override core functions.

    SYNOPSIS

    use ex::override ucfirst => sub {
    # make sure only the first
    # letter is uppercased
    ucfirst( lc( shift ) );
    };

    ucfirst( 'MAKE THIS RIGHT' );
    # Make this right

    no ex::override 'ucfirst';

    ucfirst( 'MAKE THIS RIGHT' );
    # MAKE THIS RIGHT

    "ex::override" is an easy way to override core perl functions.

    Overriding a function

    use ex::override
    length => &mylength,
    open => &myopen;

    Overriding a core function happens at compile time. Arguments are passed to "ex::override" in a name based, or hash style. The key is the name of the core function to override, the value is your subroutine to replace the core's.

    Using an overriden funtion

    Nothing changes on the surface. If you override "stat", then you still use "stat" the same way.

    NOTE: This is only true if you are keeping the same prototype as the function you've overriden. To do this, you must define your prototype:

    use ex::override values => sub (%) { values %{+shift} };

    If you don't use this same prototype or force yourself to use the function the same, you can extend the functionality of a core function:

    # length of all arguments passed to length()
    use ex::override length => sub { length join '', @_ };

    Overriding a function globaly

    Don't do this without a very good reason!

    "ex::override" allows you the ability to override core functions globaly. Any packages that inherit from yours will use your function override. There are good reasons for doing this, if you think you need to, make sure you have a good reason.

    use ex::override
    GLOBAL_length => sub {
    # prevent someone from passing a list
    croak "Don't do that!" if @_ > 1;
    length shift
    };

    NOTE: If you globaly override a function in a package, only that package can remove it.

    Removing your override

    This works the same way that "no strict" works.

    no ex::override; # remove _all_ overrides

    no ex::override 'values';

    no ex::override 'GLOABL_length';

    Requirements:

    · Perl



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    override functions | core functions | Perl module | ex::override | override | core



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM