Hi! I need some advice for this script, which I've made...
It's the line with the comment "# OKAY GUYS..." which you should look at.. Any suggestions on how to solve that problem? The script should only return results which contain ALL parameters, not just ANY of them...
Thanks in advice!
It's the line with the comment "# OKAY GUYS..." which you should look at.. Any suggestions on how to solve that problem? The script should only return results which contain ALL parameters, not just ANY of them...
Thanks in advice!
Code:
use Irssi;
use strict;
use vars qw($VERSION %IRSSI);
############ CHANGE THE LINE BELOW ###############
my $filen = "/home/baxlash/.irssi/scripts/LIST.LST"; # a list with filenames, generated by makeList.pl
my $channel = "#test";
############ DO NOT EDIT BELOW ###################
$VERSION = "0.91";
%IRSSI = (
authors => 'baxlash',
contact => 'baxlash@punkass.com',
name => 'SearchScript',
description => 'SearchScript',
license => 'Public Domain',
url => '[URL unfurl="true"]http://baxlash.mine.nu/irssi/',[/URL]
changed => 'Wed Sep 17 20:48:40 CEST 2003',
);
my $script = "SearchScript by baxlash";
Irssi::print("Loading $script v $VERSION");
Irssi::signal_add("message public", "event_pubmsg"); # add signal handler
sub event_pubmsg {
my ($server, $msg, $nick, $address, $target) = @_;
my @a = split ' ', $msg; # split $msg at whitespaces, into $a[0] $a[1] $a[2] etc
if ($target eq $channel && $a[0] eq "!search" && $a[1] ne "") {
my @result = `cat $filen | grep -i $a[1]`; # OKAY GUYS. This should be changed, since grep only allows one parameter this way...
#Irssi::print("$nick ($address) wrote in $target : $msg");
$server->send_raw("PRIVMSG $nick :This is what my search for ^B$a[1]^B returned:");
foreach (@result) {
$server->send_raw("PRIVMSG $nick :$_"); # msg every result
}
$server->send_raw("PRIVMSG $nick :End of results. ($script v $VERSION)");
}
}