Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
ad03106b
Commit
ad03106b
authored
May 08, 2012
by
Leo Gordon
Browse files
new function for finding all modules in a "directory" across the whole INC list
parent
da4b0bb0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
modules/Bio/EnsEMBL/Hive/Utils.pm
modules/Bio/EnsEMBL/Hive/Utils.pm
+32
-1
No files found.
modules/Bio/EnsEMBL/Hive/Utils.pm
View file @
ad03106b
...
...
@@ -43,7 +43,7 @@ use warnings;
use
Data::
Dumper
;
use
Exporter
'
import
';
our
@EXPORT_OK
=
qw( stringify destringify dir_revhash parse_cmdline_options load_file_or_module script_usage url2dbconn_hash)
;
our
@EXPORT_OK
=
qw( stringify destringify dir_revhash parse_cmdline_options
find_submodules
load_file_or_module script_usage url2dbconn_hash)
;
=head2 stringify
...
...
@@ -148,6 +148,37 @@ sub parse_cmdline_options {
}
=head2 find_submodules
Description: This function takes one argument ("prefix" of a module name),
transforms it into a directory name from the filesystem's point of view
and finds all module names in these "directories".
Each module_name found is reported only once,
even if there are multiple matching files in different directories.
Callers : scripts
=cut
sub
find_submodules
{
my
$prefix
=
shift
@_
;
$prefix
=~
s{::}{/}g
;
my
%seen_module_name
=
();
foreach
my
$inc
(
@INC
)
{
foreach
my
$full_module_path
(
<
$inc
/$prefix/
*.
pm
>
)
{
my
$module_name
=
substr
(
$full_module_path
,
length
(
$inc
)
+
1
,
-
3
);
# remove leading "$inc/" and trailing '.pm'
$module_name
=~
s{/}{::}g
;
# transform back to module_name space
$seen_module_name
{
$module_name
}
++
;
}
}
return
[
keys
%seen_module_name
];
}
=head2 load_file_or_module
Description: This function takes one argument, tries to determine whether it is a module name ('::'-separated)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment