Home: Perl Programming Help: Beginner:
CGI: ^M at the end of line, how to delete this ?



Ruru_atwork
Deleted

Mar 21, 2001, 12:35 AM


Views: 383
CGI: ^M at the end of line, how to delete this ?

Hello,

this is the result when i execute this script via CGI

/:os.hpux.fs:90:none:80:none:70:none^M
/home:os.hpux.fs:99:none:97:none:95:none^M
...
..
this is the script:
#!/opt/perl5/bin/perl
use CGI;
$q = new CGI;
@a = $q->param ();
$p = $q->param($a[0]);

open (FSFILE, ">/tmp/web_ar_fs_res$$");
#binmode (FSFILE);
printf FSFILE "$p" ;
close (FSFILE);

print $q->start_html(-title=>'');
system ("cat -v /tmp/web_ar_fs_res$$");
print $q->end_html();

i try with binmode but this is the same result.
How to delete ^M (or have not this character) ?


ok , i found that on forum
$p =~ s/\r//g;



(This post was edited by Ruru_atwork on Mar 20, 2001, 11:56 PM)


unknownSym
stranger

Mar 21, 2001, 12:22 PM


Views: 377
Re: CGI: ^M at the end of line, how to delete this ?

See if this helps:

$p =~ s/\s*$//g;

But now when you print the value of $p to the file use:

print FSFILE "${p}\n";

See if those two changes will work.

--unknownSym