?? grep_search1.cgi
字號(hào):
#!/usr/bin/perl -wT# WARNING: This code has significant limitations; see descriptionuse strict;use CGI;use CGIBook::Error;# Make the environment safe to call fgrepBEGIN { $ENV{PATH} = "/bin:/usr/bin"; delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) };}my $FGREP = "/usr/local/bin/fgrep";my $DOCUMENT_ROOT = $ENV{DOCUMENT_ROOT};my $VIRTUAL_PATH = "";my $q = new CGI;my $query = $q->param( "query" );$query =~ s/[^\w ]//g;$query =~ /([\w ]+)/;$query = $1;unless ( defined $query ) { error( $q, "Please specify a valid query!" );}my $results = search( $q, $query );print $q->header( "text/html" ), $q->start_html( "Simple Search with fgrep" ), $q->h1( "Search for: $query" ), $q->ul( $results || "No matches found" ), $q->end_html;sub search { my( $q, $query ) = @_; local *PIPE; my $matches = ""; open PIPE, "$FGREP -il '$query' $DOCUMENT_ROOT/* |" or die "Cannot open fgrep: $!"; while ( <PIPE> ) { chomp; s|.*/||; $matches .= $q->li( $q->a( { href => "$VIRTUAL_PATH/$_" }, $_ ) ); } close PIPE; return $matches;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -