Gossamer Forum
Home : General : Perl Programming :

Array Problem

Quote Reply
Array Problem
HI,

This has nothing to do with the Links script, but I don't know any busy "just" cgi related forums, so I
posted it here.

I have this at the top of my script somewhere:

if ($FORM{'vars'} eq "yes") {
open(MSG,">$basepath/$baseindex/mtemp.dat") | | die $!;
print MSG "$FORM{'message'}";
close(MSG);
}

open(MSG,"$basepath/$baseindex/mtemp.dat") | | die $!;
@newmessage = <MSG>;
close(MSG);

now, when I try this:

if @newmessage eq "" {
print FILE "(n/t)";
}

it will just print (n/t) no matter what.

any suggestions?


Brett
Quote Reply
Re: Array Problem In reply to
First of all, why has <MSG> been loaded into an array? Why have you opened <MSG> twice?

Try this:

if ($FORM{'vars'} eq "yes") {
open(MSG,">$basepath/$baseindex/mtemp.dat") | | die $!;
print MSG "$FORM{'message'}";
close(MSG);
}
$newmessage = $FORM{'message'};

Then try:

if ($newmessage) {
}
else {
print FILE "(n/t)";
}

------------------
WFMY-TV Webmaster
Quote Reply
Re: Array Problem In reply to
HI,

It is loaded into an array because $FORM{'message'} most likely will be multiple lines which comes from a <textarea></textarea> form tag.

I opened it twice to read in the file & set it to <MSG> as when I did it in the same opening of the file it did'nt work.

Please see my newer post on this topic under "Weird problem...help!" on this forum.

Brett