|
|
|
![]() |
||
Searching Web Sites
Simple Searching
grep (/EXPRESSION/, ARRAY); selects any elements from ARRAY for which EXPRESSION is true grep ( ) returns a subarray or ARRAY's elements @autos = qw(FordMustang, FordPinto,
FordTiempo, DodgeDart,
DodgeVolare, ChevyCamaro, ChevyMalibu) ;
@fords = grep(/Ford/, @autos); print @fords;
grep (/EXPRESSION/i, ARRAY);
@autos = qw(FordMustang, FordPinto,
FordTiempo, DodgeDart,
DodgeVolare, ChevyCamaro, ChevyMalibu) ;
@fords = grep(/ford/i, @autos); print @fords;
open (auto_file, "autos.txt") ||
die ("Can't open Autos file: $!\n"); @autos = <auto_file>; close (auto_file);
@results = grep(/$srch_arg/i,@autos); The grep ( ) function also returns the number
of items found in the subarray name
parse_input (*fields); $srch_arg = $fields{'car_name'};
@results = grep(/$srch_arg/i,@autos);
if ($#results > 0){
do something;
}
|
||
|
||