My development is split between Windows XP and Linux. Even on Windows, I do most of my programming from the command-line. Recently, I thought it would be nice to launch a browser with a query to http://search.cpan.org straight from the command line:
> searchcpan Class::InsideOut
I also adapted the pseudo-URL style from perlmonks:
> searchcpan mod://Storable > searchcpan dist://Test-Simple > searchcpan author://dagolden
To get this working, I installed the following simple code as C:\perl\bin\searchcpan.pl and then ran pl2bat searchcpan.pl in that directory.
# searchcpan.pl use strict; use warnings; my %modes = ( "mod://" => "module", "dist://" => "dist", "author://" => "author", ); my $url = "http://search.cpan.org/search?query=QUERY;mode=MODE"; my $target = shift; if ( ! $target ) { $url =~ s{/search\?.+}{}; } else { my ($mode) = grep { $target =~ qr/\A$_/ } keys %modes; if ( defined $mode ) { $target =~ s{\A$mode}{}; $url =~ s{MODE}{$modes{$mode}}; $url =~ s{QUERY}{$target}; } else { $url =~ s{QUERY}{$target}; $url =~ s{MODE}{all}; } } system('C:\windows\system32\cmd.exe', "/C start $url" );
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Launch CPAN search in browser from Windows command shell
by demerphq (Chancellor) on Apr 07, 2006 at 07:13 UTC | |
|
Re: Launch CPAN search in browser from Windows command shell
by PodMaster (Abbot) on Apr 08, 2006 at 22:56 UTC | |
|
Re: Launch CPAN search in browser from Windows command shell
by zentara (Cardinal) on Apr 07, 2006 at 11:46 UTC | |
by xdg (Monsignor) on Apr 07, 2006 at 13:30 UTC | |
by rhesa (Vicar) on Apr 07, 2006 at 15:17 UTC | |
|
Re: Launch CPAN search in browser from Windows command shell
by rinceWind (Monsignor) on Apr 07, 2006 at 09:00 UTC |