Hi,
I am writing a perl script to work on web.
I dont have any problem while displaying static data.
I modufied my script to acces a file and display the contents. On command line the script works fine. But when I open the script using web page on Apache server I am unable to display the contents of the target file. Funny part is, except the data from file I am getting entire static data on the web page.
Please help me to solve this problem.
#!/usr/bin/perl
my $cfgfile="./dbconnect";
open (CONFIG,$cfgfile);
while (<CONFIG>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
$value=~ s/\r//g;
$ConfigValue{$var} = $value;
}
print "Name--$ConfigValue{'NAME'}";
--------------------
The above script works fine on CLI but on web I get
only "Name--" displayed.
Edit: g0n - code tags
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.