Oh and a few additional problems I caught:

At 02:09 PM 07/25/2001 +0530, Rahul Garg wrote:
>the code goes like this :
>
># !usr/bin/perl -w
  ^--- This space shouldnt be here. This alone will 
       stop your script from running from the get-go.
        (Unless of course you specify the perl interpreter
       directly from the commandline)
       

>print <<"Endoftext";
>Content-type: text/html
><html>........</html>
>Endoftext         

AFAIK, it's customary to use an uppercase name for Here-doc delimiter
strings. Otherwise it can be a bit confusing sometimes to see what
otherwise looks like a bareword in the middle of a big chunk of code.

>$mailids = $query->param('mailid') ; 
>for($mailids)
>{
>s/^\s//;
>s/\s+$//;
>}

This seems a bit strange to me...Why are you using a for loop on a single
parameter? Or does the 'mailid' parameter contain a list of values from a
radiobutton group or something?

>
> $file =/var/www/cgi-bin/cgirahul/cli.txt ;

Big problem. This code doesn't even compile! You need to put quotes around
the path, otherwise Perl thinks you're trying to do some sort of wierd
pattern-match or something and chokes.

>$old = $file ;

This is kind of a useless use of a temp variable, imo. You can just use 
"$file" in the places where you are using "$old", since nothing happens to
the $file variable once you initially set its value...Though I can
understand that you probably did this for clarity, since you created
similar variablenames such as $new and $bak. 

>$new =$file.tmp.$$" ;

MAJOR syntax error. Where's the beginning quote?


>print"SHEEEEEEEEEEEE";      

This code will work, but you need to put a space between the print
statement and the string to be printed. This as it stands is pretty
unreadable.

>open(OLD,"< $old") or die "cant open $old: $!";
>print "HEEEEEEEEE" ;     #########             fine till here

This shouldn't be "fine", because $old is a copy of $file, which shouldn't
have been assigned in the first place, since your script should have bombed
out with a syntax error back when you tried to load the path/file name into
the $file variable.


>open(NEW,"> $new") or die "cant open $new: $!";  #######not opening 

It's not opening because there is no "$new" at that point, because $new
depends on $file having been properly assigned, which it wasn't because of
the syntax error.


>Waiting for Reply.........
>Thanx in Advance,
>Rahul

You need to do some major /basic/ debugging of this code. 

A few tips:

1. ALWAYS 'use strict'. This will force you to adhere to good programming
standards, and will help you prevent writing buggy code in the first place.

2. Don't use global variables! Use "my" to set the scope of all your
variables, for example:

        my $mailids;
        $mailids = $query->param('mailid'); 

        Or, to be more succinct:
        
        my $mailids = $query->param('mailid'); 

3. Test your code before posting to the list. Your code has numerous
*basic* syntax errors that you should have seen if you tried to run the
script from the commandline. There are places in the code where you say
"fine till here", but in reality, it shouldn't have been "fine" at all,
because you would have seen the syntax errors pop up.

HTH. Aloha,
mel




--
mel matsuoka                    Hawaiian Image Productions
Chief Executive Alphageek              (vox)1.808.531.5474
[EMAIL PROTECTED]                  (fax)1.808.526.4040

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to