Having a method with the same name as a builtin
This example shows how a module can have a method which has the same
name as an existing builtin. In this case the
module Fruit
has a method called read
.
package Fruit; require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw//; use warnings; use strict; sub new { return bless {}; } sub Fruit::read { print "OK\n"; } 1;
Using the qualified name, the module now has a method read
:
#!/usr/bin/perl use warnings; use strict; use Fruit; my $fruit = Fruit->new (); $fruit->read ("boxes.txt");
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com).
/
Privacy /
Disclaimer