A \@chan (\#\w+) print "PART $chan :chan\n"; $chan = $1; print "JOIN $chan\n"; open(NICK_OPEN,"config"); my @temp_nick = ; close NICK_OPEN; open(NICK_WRITE,">config"); foreach(@temp_nick) { if (/^\$chan/) { print NICK_WRITE "\$chan=\"$chan\";\n"; } else { print NICK_WRITE "$_"; } } close NICK_WRITE;