Though its not recommended but some times we are in need to change or extend the core functionality of inbuilt Perl function/ subroutine.
This can be easily implemented in the following way. I have created a small gist for changing the core functionality.( Just for fun)
You can read it more in perdoc .
This can be easily implemented in the following way. I have created a small gist for changing the core functionality.( Just for fun)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#override the core subroutine (inbuilt function) of perl | |
BEGIN { | |
*CORE::GLOBAL::chdir = sub { | |
print "perl core funtion override sample"; | |
} | |
*shove = \&CORE::push; | |
} | |
chdir ; | |
# CORE::chdir #"Still u can access the core function using this way\n"; | |
shove @arr,1; |
You can read it more in perdoc .
No comments:
Post a Comment