Hello Monks, I have a weird question.
My String module has a hash reference:
and has an AUTOLOAD subroutine:$reg = { url => qr[^http://], };
so I can use "is_**" subroutine and add new regix whenever I want, for example, I add like:sub AUTOLOAD { our $AUTOLOAD; my $arg = shift; if ($AUTOLOAD =~ /^is_/) { my $key = substr $AUTOLOAD, 3; my $val = $reg->{$val}; return 1 if $arg =~ /$val/; } }
so I can use "is_file" subroutine.$reg = { url => qr[^http://], file => qr[^[a-Z]:/], };
Then, to avoid typing String::is_url($str) but just is_url($str) on another file, I want to export "is***" subroutine by using Export.
To do so, I added this code:
But it does not load AUTOLOADed subroutine "is_**" because it will be loaded when it's called.use Export; our @EXPORT = do { no strict 'refs'; grep {*$_{CODE}} keys %Str::; };
Are there any way to call "is_***" without "String::" from another module?
Thanks in advance!
In reply to How to export un-exist subroutines by ryo0ka
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |