Gossamer Forum
Home : General : Perl Programming :

figuring out if you have a module..

Quote Reply
figuring out if you have a module..
well.. i was trying to figure out if my server (digitalspace) had a few modules that is needed for alias-mail and was tired of waiting for response.. so i just put something together to figure it out..

http://www.widgetz.com/modules.cgi

that is on hypermart.. the last few lines are their stupid popup code.. just ignore that..

anyways.. if you'd like the code.. i'll pass it on.. jsu7785@email.com

jerry
Quote Reply
Re: figuring out if you have a module.. In reply to
Jerry (Widgetz),

Nice script. I think it will be very useful for Perl and CGI programmers who need to find out about what modules are available in their web accounts.

I'd like the codes, if you don't mind.

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: figuring out if you have a module.. In reply to
stop directly addressing me as Jerry (Widgetz)!! Smile

since the script is so short...

Code:
#!/usr/local/bin/perl

use strict;
use File::Find;
my (@mod, %done, $dir);

find(\&get, grep { -r and -d } @INC);
@mod = grep(!$done{$_}++, @mod);

foreach $dir (sort { length $b <=> length $a } @INC) {
foreach (@mod) { next if s,^\Q$dir,,; }
}

print "Content-type: text/plain\n\n";
foreach (@mod) { s,^/(.*)\.pm$,$1,; s,/,::,g; print "$_\n"; }
print "Done! ($#mod modules!)\n\n";

sub get { /^.*\.pm$/ && /$ARGV[0]/i && push @mod, $File::Find::name; }

you need File::Find. .but that is usually already installed..

i was going to make the script so you can just type the module name..

like LWP/Simple.pm or LWP::Simple and it will return yes or no if you have it..

but what the heck.. i like to know what i have totally Smile

i'm looking at making the script into a find file script though.. so i can search for files in my DIR Smile

jerry

[This message has been edited by widgetz (edited November 08, 1999).]
Quote Reply
Re: figuring out if you have a module.. In reply to
forgot to mention.. if you put

http://www.url.to/modules.cgi?LWP

it will find all LWP modules..

jerry
Quote Reply
Re: figuring out if you have a module.. In reply to
sorta like this thing i just put together.. not sure if the speed is good.. but it's grep so.. hehe

www.pdamania.com/find.cgi

it searches in my directory.. i wanted to make this for a FTP simulator perl script that i am making for a company.. it's like a windows FIND Smile

anyways.. i have a secret file that some of you might want to look at.. Smile search for it.. it's in viewable format.. not encrypted.. hehe.. it's a treasure hunt..

also.. all admin and secret directories are currently parsed out..

*hint* regexp work too

jerry

[This message has been edited by widgetz (edited November 07, 1999).]
Quote Reply
Re: figuring out if you have a module.. In reply to
So simple and short, yet very informative.
Thanks for sharing! Smile
Quote Reply
Re: figuring out if you have a module.. In reply to
Thanks Widgetz.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: figuring out if you have a module.. In reply to
widgetz, nice script!

Try searching for a dot as in yahoo.com ... you know just "." without
quotes Smile
It returns so many files and directories. I guess it returns the whole tree. Or what??

Thanks for the code!




------------------
Complete Index of Web Master's Resources: http://www.cellwarp.com
Quote Reply
Re: figuring out if you have a module.. In reply to
it's suppose to.. "." means anything in REGEXP

you can change it to \. to search for periods..

jerry
Quote Reply
Re: figuring out if you have a module.. In reply to
Very nice, Widgetz. I installed it and it works very well.

However, why do your scripts typically NOT work in MIE 4.0??

I tried executing it via MIE 4.0 and get that annoying plug-in error.

Weird...since the Content-type should allow the variables to print out.

No biggie though, since I usually run these types of scripts via telnet. Although I am unable to add arguments like ?LWP. Oh well.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: figuring out if you have a module.. In reply to
Eliot, try this...

#!/usr/bin/perl
use strict;
use File::Find;
my (@mod, %done, $dir);
find(\&get, grep { -r and -d } @INC);
@mod = grep(!$done{$_}++, @mod);
foreach $dir (sort { length $b <=> length $a } @INC) {
foreach (@mod) { next if s,^\Q$dir,,; }
}
print "Content-type: text/html\n\n";
foreach (@mod) { s,^/(.*)\.pm$,$1,; s,/,::,g; print "$_<br>\n"; }
print "Done! ($#mod modules!)\n\n";
sub get { /^.*\.pm$/ && /$ARGV[0]/i && push @mod, $File::Find::name; }

This works fine with IE5 and NS 4.08

------------------
Larry "NgtCrwlr" Mingus
www.makeitsimple.com
Quote Reply
Re: figuring out if you have a module.. In reply to
Very cool! I don't know why the \n is not interpreted in MIE 4.0. Anyway, it works fine now.

I noticed that there are a lot of redundant modules that I installed (thinking that my hosting company did not have them installed).

Cool...very cool.

Thanks.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------