Xchat::register("Cyth's Pimpbot Question Adder","1.0"); Xchat::hook_command("addq","add",{ help_text => "Yeah, you need help.\n" }); sub add { my $file = $_[0][1]; if ($ENV{'HOME'}) { my $home = $ENV{'HOME'} } else { Xchat::print "environment variable \$HOME is not set.\n"; return; } my $questionfile = "$home/$file.txt"; if(-e $questionfile){ open(QUESTIONFILE, "$questionfile") or Xchat::print("cannot open file $questionfile: $!") and return; while(){ chomp; Xchat::command("say \@add $_"); sleep 5; } close(QUESTIONFILE); } return Xchat::EAT_ALL; }