LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-15-2008, 05:04 PM   #1
breeze99
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Rep: Reputation: 0
Perl - How to get names of subroutines that found under a name space?


Hi, please advise ..
I need to get sub names that existed in a defined namespace ..
Just like it can be done in TCL:
Code:
 
puts "Here are all procs: [info procs ::mynamespace::*]"
puts "Here are all vars:  [info vars ::mynamespace::*]"
Case:
Code:
#################################################
use myPack_01;
  foreach $sub (&Some_how_get_subs_names_from(::myPack_01)) {
    print "Executing $sub ..\n";
    &{myPack_01::$sub};
  };
#################################################
package MyPack_01;
my $var1;
sub abcd {};
sub dddd {};
1;
#################################################
And/Or test its existance ..
if (exists ::myPack_01::abcd) {print "Ok\n"};

Thanks a lot ..

Last edited by breeze99; 09-15-2008 at 05:07 PM.
 
Old 09-15-2008, 05:46 PM   #2
haytona
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Rep: Reputation: 0
Try this:

Code:
perl -e 'use Data::Dumper; print join(", ", grep {defined &{"Data::Dumper::$_"}} sort keys %{"Data::Dumper::"}), "\n"'
Just replace Data:;Dumper with your own module.

(lifted from here: http://gwolf.org/blog/show/Introspection-in-Perl)
 
Old 09-16-2008, 01:41 PM   #3
breeze99
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by haytona View Post
Try this:

Code:
perl -e 'use Data::Dumper; print join(", ", grep {defined &{"Data::Dumper::$_"}} sort keys %{"Data::Dumper::"}), "\n"'
Just replace Data:;Dumper with your own module.

(lifted from here: http://gwolf.org/blog/show/Introspection-in-Perl)

Great .. thanks.
 
  


Reply

Tags
perl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
space in file names man_linux Linux - General 3 09-20-2006 06:32 PM
perl - passing values to subroutines sporty Programming 7 08-08-2006 09:13 AM
(Perl) Dereferencing arrays for subroutines Poetics Programming 7 05-23-2006 05:27 PM
script #!/bin/bash, problem with space in file names existent Linux - General 3 06-17-2004 08:13 AM
What are some names of tools for checking disk space aaronruss Linux - Newbie 2 06-08-2004 10:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration