File::Find::Rule::Extending - Online Linux Manual PageSection : 3
Updated : 2022-01-21
Source : perl v5.34.0
Note : User Contributed Perl Documentation
NAMEFile::Find::Rule::Extending − the mini−guide to extending File::Find::Rule
SYNOPSIS package File::Find::Rule::Random;
use strict;
# take useful things from File::Find::Rule
use base 'File::Find::Rule';
# and force our crack into the main namespace
sub File::Find::Rule::random () {
my $self = shift()−>_force_object;
$self−>exec( sub { rand > 0.5 } );
}
1;
DESCRIPTIONFile::Find::Rule went down so well with the buying public that everyone wanted to add extra features. With the 0.07 release this became a possibility, using the following conventions.
Declare your package package File::Find::Rule::Random;
use strict;
Inherit methods from File::Find::Rule # take useful things from File::Find::Rule
use base 'File::Find::Rule';
Force your madness into the main package # and force our crack into the main namespace
sub File::Find::Rule::random () {
my $self = shift()−>_force_object;
$self−>exec( sub { rand > 0.5 } );
}
Yes, we're being very cavalier here and defining things into the main File::Find::Rule namespace. This is due to lack of imaginiation on my part − I simply can't find a way for the functional and oo interface to work without doing this or some kind of inheritance, and inheritance stops you using two File::Find::Rule::Foo modules together. For this reason try and pick distinct names for your extensions. If this becomes a problem then I may institute a semi-official registry of taken names.
Taking no arguments.Note the null prototype on random. This is a cheat for the procedural interface to know that your sub takes no arguments, and so allows this to happen: find( random => in => '.' );
If you hadn't declared random with a null prototype it would have consumed in as a parameter to it, then got all confused as it doesn't know about a '.' rule.
AUTHORRichard Clamp <richardc@unixbeard.net>
COPYRIGHTCopyright (C) 2002 Richard Clamp. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSOFile::Find::Rule File::Find::Rule::MMagic was the first extension module, so maybe check that out. 0
Johanes Gumabo
Data Size : 8,097 byte
man-File::Find::Rule::Extending.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 6 / 168,181
Visitor ID : :
Visitor IP : 3.147.75.217 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|File::Find::Rule::Extending.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|File::Find::Rule::Extending.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|File::Find::Rule::Extending.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|File::Find::Rule::Extending.3pm|43|'br══─}─══ |'br══─}─══
)