Asked By
Blaine Back
0 points
N/A
Posted on - 08/27/2011
Hey,
Following is the script in perl.
#!/usr/bin/perl
open(TXT, "<nonsuch.txt") || $error($!);
@data = < TXT >;
close(TXT);
print "Content-type:text/htmlnn <html>";
foreach $item(@data)
{
print "<li>" $item";
}
print "</html>";
sub error
{
print "Content-type:text/htmlnn";
print "<html><h3>Error: $_[0] </h3></html>";
}
I got errors while running this script. Please help me in this regard…
Script error in perl programming…
Hi Blaine,
I would love to help you but how can I help you if you don’t really give the exact error in your program. I mean the error code if you have. So here is my suggestion about your issue. Try to recheck all of you code in your program. And canvass come research about your work. Then analyze all of your code and the flow of your program. Then extract all it in your program. As I remembered they out the new upgrade perl the PERL5. Little info about the PERL5. Perl 5 is a awful capable, feature-rich programming accent with over 23 years of development. Perl 5 runs on over 100 platforms from portables to mainframes and is acceptable for both accelerated prototyping and ample calibration development projects.
"Perl" is a ancestors of languages, "Perl 6" is allotment of the family, but it is a abstracted accent which has it's own development team, it's actuality has no cogent applies on the continuing development of "Perl 5". So keep on trying man. Good luck and happy programming. Thanks.
Script error in perl programming…
Hi Blaine,
When I ran your script this is the first error:
syntax error at ./script.pl line 2, near "$error("
BEGIN not safe after errors–compilation aborted at ./script.pl line 3.
Problem : $error($!) – – – this is a wrong syntax use command die instead
Solution : die $!
Next ran another errors showed:
Scalar found where operator expected at ./script.pl line 8, near ""<li>" $item"
(Missing operator before $item?)
String found where operator expected at ./script.pl line 10, near "print ""
(Might be a runaway multi-line "" string starting on line 8)
(Missing semicolon on previous line?)
Backslash found where operator expected at ./script.pl line 13, near "html"
(Might be a runaway multi-line // string starting on line 10)
Backslash found where operator expected at ./script.pl line 13, near "n"
String found where operator expected at ./script.pl line 14, near "print ""
(Might be a runaway multi-line "" string starting on line 13)
(Missing semicolon on previous line?)
Bareword found where operator expected at ./script.pl line 14, near "<h3>Error"
(Missing operator before Error?)
syntax error at ./script.pl line 8, near ""<li>" $item"
Can't find string terminator '"' anywhere before EOF at ./script.pl line 14.
Problem : print "<li>" $item"; – – – Missing the + symbol to concatenate string and lacking ” before $item
Solution : print "<li>" + “$item" proper concatenation
Last ran:
No such file or directory at ./script.pl line 2.
Problem : open(TXT, "<nonsuch.txt") – – – wrong syntax
Solution : open TXT, "<nonsuch.txt"