I want to do certain things if -e $info, but I'm getting uninitialized value errors on the code inside the if statements. The only reason I would get the error is if $info doesn't exist, but in that case the if statement shouldn't continue. Right?
I've tried this:
if ((-e $info) and ($query =~ /support/))
{
open (FILE, $info) or die "Can't open file!";
print while <FILE>;
close FILE;
}
if ((-e $info) and ($query ne /support/))
{
print "<a href\=\"$webdir/cgi-bin/getprods.pl?$prodlisting\">";
print "Product Listing</a><br><br>";
open (FILE, $info) or die "Can't open file!";
print while <FILE>;
close FILE;
}
and this
if (-e $info)
{
if ((-e $info) and ($query =~ /support/))
{
open (FILE, $info) or die "Can't open file!";
print while <FILE>;
close FILE;
}
if ((-e $info) and ($query ne /support/))
{
print "<a href\=\"$webdir/cgi-bin/getprods.pl?$prodlisting\">";
print "Product Listing</a><br><br>";
open (FILE, $info) or die "Can't open file!";
print while <FILE>;
close FILE;
}
}
And, another problem:
If I use:
if ((-e $info) and ($query ne /support/))
it returns true no matter what (with ne)
but if I use an arithmatice operator it returns false, when it should, but gives me an error message about using the wrong type of operator.
Thank you
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.