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.
In reply to Launch CPAN search in browser from Windows command shell by xdg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |