Web Hosting Talk







View Full Version : Print to text file.


-Edward-
10-15-2000, 05:58 PM
First i think you need a scripting forum :).

I've tryed over at sitepoint now im going to try here i know its this part of the script now thats wrong : -

sub printaddr {
open (data, ">>$banlist");
@data=<data>;
close(data);
foreach $data(@data) {
@datax=($data);
unless ($input{'ipnumber'} eq "@datax[0]") {
open(ip, ">>$banlist");
print ip "$input{'ipnumber'}\n";
close(ip);
}
}
}


What inside that coding looks wrong?. i'm trying to get it to print an ip address to a text file. So if i typed in 234.234 and pressed enter the script would print it to the file but this coding dont ive played about with it for nearly 4 hours now some help or even a solution would be great.

JTY
10-15-2000, 06:47 PM
unless ($input{'ipnumber'} eq "@datax[0]") {

should be, if my perl knowledge is still good,

unless ($input{'ipnumber'} eq @datax[0]) {

-Edward-
10-15-2000, 06:54 PM
did not do the script any harm that code but still doesnt print ..... ill give all the coding after this part too it could still be in the end part.

sub get_input {

if($ENV{'REQUEST_METHOD'} =~ /get/i)
{
@pairs=split(/&/,$ENV{'QUERY_STRING'});
}
else
{
$buffer = "";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$buffer);
}
foreach $pair (@pairs)
{
@a = split(/=/,$pair);
$name=$a[0];
$value=$a[1];
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$value =~ s/\+/ /g;
$value =~ s/(\r)+/\-\-/g;
$value =~ s/\n+//g;
push (@input,$name);
push (@input,$value);
}
%input=@input;
%input;
}

That is straight after the coding. Thanks for the last peice though JTY.