malkie
asked on
Read and write file (part 2)
Further on with Read and write file.
-------
#!/usr/bin/perl
open I,"<info.txt" or die "Can't open info.txt $!";
open E,">enter.tab" or die "Can't open enter.tab $!";
$/="-------------\n";
while( <I> ){
chomp;
@l=split/\n/;
@l = grep !/<input\s+type=(submit|re set)\b/i,@ l;
@i{"text","hidden"}=();
for( @l ){
if( /<input\s+type\s*=\s*(\S*) .*\bname\s *=\s*(["'] ([^"']*)[" ']|(\S*)). *?\b(value \s*=\s*([" ']([^"']*) ["']|(\S*) )).*>/
){
$i{lc $1} .= "$3$4=$7$8,";
}elsif( /<input\s+type\s*=\s*(\S*) .*\bname\s *=\s*("([^ "]*)"|(\S* )).*>/
){
$i{lc $1} .= "$3$4=$3$4,";
}
}
chop @i{"text","hidden"};
#print E join("\t",$l[0],"General", $l[2],$l[1 ],"http://yes/image.gif",@l[3, 4],@i{"tex t","hidden "},"0"),"\ n";
print E join("\t",$l[0],"General", $l[2],$l[1 ],"http://yes/image.gif",@l[3, 4],@i{"tex t","hidden "},"Thank You","0"),"\n";
}
----------
The script needs to write the first line to enter.tab to set field names as:-
Code"\t"Category"\t"Descri ption"\t"H omeUrl"\t" LogoUrl"\t "SubmitUrl "\t"Method "\t"Varmap "\t"Static Vars"\t"Su ccess"\t"D efault
The script needs to be able to be called from the browser.
-------
#!/usr/bin/perl
open I,"<info.txt" or die "Can't open info.txt $!";
open E,">enter.tab" or die "Can't open enter.tab $!";
$/="-------------\n";
while( <I> ){
chomp;
@l=split/\n/;
@l = grep !/<input\s+type=(submit|re
@i{"text","hidden"}=();
for( @l ){
if( /<input\s+type\s*=\s*(\S*)
){
$i{lc $1} .= "$3$4=$7$8,";
}elsif( /<input\s+type\s*=\s*(\S*)
){
$i{lc $1} .= "$3$4=$3$4,";
}
}
chop @i{"text","hidden"};
#print E join("\t",$l[0],"General",
print E join("\t",$l[0],"General",
}
----------
The script needs to write the first line to enter.tab to set field names as:-
Code"\t"Category"\t"Descri
The script needs to be able to be called from the browser.
ASKER
Software error:
syntax error at C:\Inetpub\wwwroot\cgi-bin \extractht ml\ozo3.cg i line 6, near "'Read and write file (part 2)';"
Execution of C:\Inetpub\wwwroot\cgi-bin \extractht ml\ozo3.cg i aborted due to compilation errors.
For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.
syntax error at C:\Inetpub\wwwroot\cgi-bin
Execution of C:\Inetpub\wwwroot\cgi-bin
For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is great had to make a small change to the paths in the script Thank You again
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
print $q->header,
$q->start_html('Read and write file (part 2)';
open I,"<info.txt" or die "Can't open info.txt $!";
open E,">enter.tab" or die "Can't open enter.tab $!";
print E "Code\tCategory\tDescripti
$/="-------------\n";
while( <I> ){
chomp;
@l=split/\n/;
@l = grep !/<input\s+type=(submit|re
@i{"text","hidden"}=();
for( @l ){
if( /<input\s+type\s*=\s*(\S*)
){
$i{lc $1} .= "$3$4=$7$8,";
}elsif( /<input\s+type\s*=\s*(\S*)
){
$i{lc $1} .= "$3$4=$3$4,";
}
}
chop @i{"text","hidden"};
#print E join("\t",$l[0],"General",
print E join("\t",$l[0],"General",
}
close E;
close I;
print $q->end_html;