Gossamer Forum
Home : Products : DBMan : Customization :

grep code explanation

Quote Reply
grep code explanation
would someone please explain to me the line that contains grep? i'm trying to understand it so i can use it elsewhere. thanks

Code:
my ($column, $value, $size) = @_;
my (@fields, @values, $output);
$size or ($size = 1);
if ($mult) { @values = split (/\Q$db_delim\E/,$value); }
else { @values = ($value); }
@fields = split (/\,/, $db_select_fields{$column});
if (! exists ($db_select_fields{$column})) {
$output = "error building select field: no fields specified/unkown field ($column)!";
}
else {
$output = qq|<SELECT NAME="$column" MULTIPLE SIZE=$size><OPTION>---|;
foreach $field (sort @fields) {
if (grep $_ eq $field, @values) {
$output .= "<OPTION SELECTED>$field\n";