http://www.google.com/search?q=cool+uses+for+perl #### #!/usr/bin/perl package browse; use warnings; use strict; use Exporter (); @ISA = qw(Exporter); @EXPORT_OK = qw( jeeves google dictionary thesaurus ); use Getopt::Long; our %pars; sub browser_cmdline { DoGetOptions () if scalar @ARGV; my $site = shift () or die "no site in browse::browser_cmdline\n"; my $bDontUseArgv = shift () || 0; my $sSearch = join '+', @ARGV unless $bDontUseArgv; # Replace quotes with http friendly %22-s, and replace whitespace with # query-friendly '+'-s # $sSearch =~ s/"/%22/g; $sSearch =~ s/\s+/+/g; $site .= $sSearch; my $str = ( $pars{browser} eq '' ) ? "lynx -cookies A $site " : ( $pars{browser} =~ /^m/ ) ? mozilla_path () . " $site &" : netscape_path () . " $site &"; print "$str\n" and return if $pars{norun}; system $str; } sub jeeves { browser_cmdline 'http://www.ask.com/main/askjeeves.asp?ask='; } sub google { browser_cmdline 'http://www.google.com/search?q='; } sub dictionary { browser_cmdline 'http://dictionary.reference.com/search?q='; } sub thesaurus { browser_cmdline 'http://thesaurus.reference.com/search?q='; } sub DoGetOptions { %pars = ( browser => "", norun => 0, help => 0, usage => 0, ); GetOptions ( \%pars, 'browser=s', 'norun', 'help', 'usage', ) or die "bad options $!"; my $help_txt = qq{\tgoogle/jeeves/dictionary/thesaurus \t[-browser] [-norun] [-help] [-usage] \tsearch words list google and jeeves perform a search (at the expected location) on the given words. dictionary looks up the first word on dictionary.com. Quoted strings must be enclosed in single quotes: google '\"one two three\"' -browser n[etscape] launches the search in netscape7, -browser m[ozilla] launches the search in mozilla (default is lynx). -norun prints out the search URL, but doesn't load it.\n}; die $help_txt if $pars{help} || $pars{usage}; } sub netscape_path { "/usr/local/bin/netscape" } sub mozilla_path { "/usr/local/bin/mozilla" } 1; #### #!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( dictionary ); dictionary (); #### #!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( google ); google (); #### #!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( thesaurus ); thesaurus (); #### #!/usr/bin/perl use warnings; use strict; use lib '/home/kester/bin/'; use browse qw( jeeves ); jeeves ();