in reply to Re: Always leaving one space in file
in thread Always leaving one space in file

I tried this with no success:

my $list; my @changes = param('tellmessage'); ###################### if (@changes eq " ") { exit } ###################### open(FILE, ">eetnlinks.txt") || die "Can't open file!"; flock(FILE, 2) || die "Can't lock file!"; #truncate(FILE,0); foreach $list (@changes) { chomp ($list); print FILE "$list\n"; } close(FILE);
Or could I count the length of @changes and compare it:
if (@changes > 1) { exit; }
If that would work, I don't know how to count the length of the string... ?

Replies are listed 'Best First'.
Re: Re: Re: Always leaving one space in file
by vek (Prior) on Apr 23, 2003 at 15:31 UTC
    Try not opening the file unless you have data in the @changes array:
    if (@changes) { # do stuff here }
    I don't know how to count the length of the string...?:
    my $length = length $some_string;
    -- vek --
Re: Re: Re: Always leaving one space in file
by zby (Vicar) on Apr 23, 2003 at 15:32 UTC
    Why do you insist on a list? Does the tellmesage parameter contain multiple values? If it was a textarea than it contains just one value and you can retrieve it with:
    my $change = param('tellmessage');
      It is a TEXTAREA not a TEXTBOX

      There is one link perline separated by a pipe "|"

      my site|http://www.whatever.com|blank
      I tried using $change, but it wouldn't work :(
        A textarea is just one value - exactly like textbox. Just try the example presented in the pod for CGI (perldoc CGI) and changet the textbox to textarea - everything will work.
Re: Re: Re: Always leaving one space in file
by Anonymous Monk on Apr 23, 2003 at 15:32 UTC
    what I meant was:
    if (@changes eq " ") { @changes eq ""} }