CHOMP not working 
Author Message
 CHOMP not working

Here is the source in question:

<TR>
        <TD VALIGN="middle"><A

        <TD VALIGN="middle">Geoto</td>
        <TD VALIGN="middle">Streetsboro, OH
</td>
</TR>
<TR>
        <TD VALIGN="middle"><A

        <TD VALIGN="middle">FuzzyLogix</td>
        <TD VALIGN="middle">Akron, OH
</td>
</TR>
<TR>
        <TD VALIGN="middle">&nbsp;</td>
        <TD VALIGN="middle">GymSlayer</td>
        <TD VALIGN="middle">Somewhere, IN</td>
</TR>

notice how the first two </td>'s go to a new line while the last one
doesn't.  This seems like there is still a newline character in the
variable.  I tried chomping both that variable and the line whole line
(before spliting) multiple times and it never changed.  It worked when i
used the chop function, but then the last location is "Somewhere, I"  I
have also tried taking out all of the chomp functions to see if it
looked different and it didn't.  Here are all the different ways I have
tried it ($df_location is the name of that variable):

chomp $_;  # chomp the line before spliting it
chomp($_); # another variation of the chomp comman I have seen
chomp $df_location; #chomping the variable after the split
chomp($df_location); # alt ver

none of those worked.

--
Todd Eddy

http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 CHOMP not working

Quote:
> Here is the source in question:

Maybe I missed something, but can you post your Perl source and not what
it outputs?

bean



Wed, 18 Jun 1902 08:00:00 GMT  
 CHOMP not working
Remember that perl only chomps the \n off the end of a line, not any
embedded within the line! Thus...

$x = 'aaaaaa' . "\n" . 'zzzzzzz' . "\n";

print "$x";
print "Before the chomp\n";
chomp($x);
print "$x";
print "After the chomp\n";

Gives us...

aaaaaa
zzzzzzz
Before the chomp
aaaaaa
zzzzzzzAfter the chomp

Note that the 'After the chomp' is now appended onto our test line but
the break between the 'a's and the 'z's is intact. If it is an embeded
'\n' you are having to kill of you might want to try...

$x =~ s/\n//gi;

Thus...

$x = 'aaaaaa' . "\n" . 'zzzzzzz' . "\n";

print "$x";
print "Before the chomp\n";
$x =~ s/\n//gi;
print "$x";
print "After the chomp\n";

Gives...

aaaaaa
zzzzzzz
Before the chomp
aaaaaazzzzzzzAfter the chomp

What you probably wanted.

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 CHOMP not working

Quote:

> Here is the source in question:

Er, no it isn't - that's the output.

Please show us the source.

Quote:
> --------------1E90B7231D8C82985C93E699
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit

> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">

If is not a binary newsgroup - please post plaintext only.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Wed, 18 Jun 1902 08:00:00 GMT  
 CHOMP not working
OK, here is what I am getting in the HTML source when I go to
http://www.vrillusions.com/cgi-bin/whoscoming/whoscoming.cgi?date=8/1...
:

<TABLE WIDTH=500 BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TH ALIGN="left" WIDTH=150>Name</TH>
<TH ALIGN="left" WIDTH=175>Call Sign</TH>
<TH ALIGN="left" WIDTH=175>Location</TH>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2><A

        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>Geoto</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>Streetsboro, OH
</FONT></TD>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2><A

        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>FuzzyLogix</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Akron, OH
</FONT></TD>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>&nbsp;</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>GymSlayer</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Somewhere,
IN
</FONT></TD>
</TR>
<TR>
        <TD VALIGN="middle"><FONT FACE="verdana,arial"
SIZE=2>Conan</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Conan the
Barbarian</FONT></TD>
        <TD VALIGN="middle"><FONT FACE="verdana,arial" SIZE=2>Unknown,
CA</FONT></TD>
</TR>

</TABLE>

Notice how the </FONT></TD> is on a new line?  Thats what I am trying to
figure out.  Here is the Source from the script:

# HTML Section
##############
# Loading HTML settings
require 'htmlsettings.pl';

print qq~
<HTML><HEAD>
<TITLE>Attendees for $date</TITLE>
</HEAD>
<BODY BGCOLOR="$html_bgcolor" TEXT="$html_text" LINK="$html_link"
VLINK="$html_vlink" ALINK="$html_alink">

<CENTER><H2>Here are the people registered for the $date LAN party</H2>
<P>
<TABLE WIDTH=500 BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TH ALIGN="left" WIDTH=150>Name</TH>
<TH ALIGN="left" WIDTH=175>Call Sign</TH>
<TH ALIGN="left" WIDTH=175>Location</TH>
</TR>
~;

open (FILE, "$datalocation") or print "<TR><TD>&nbsp;</TD></TR>\n<TR><TD
ALIGN=\"center\" NOWRAP COLSPAN=3><B><FONT FACE=\"verdana,arial\" SIZE=4
COLOR=\"$html_error\">Failed to open data
file</FONT></B></TD></TR>\n<TR><TD ALIGN=\"center\" NOWRAP
COLSPAN=3><FONT FACE=\"verdana,arial\" SIZE=2>This usally means that no
one has registered for this date yet<BR>\nor that the date is
incorect</FONT></TD></TR>";
while (<FILE>) {
 # chomp($_);
 # Now split up the info:
showname|name|showemail|email|callsign|location
 ($df_showname, $df_name, $df_showemail, $df_email, $df_callsign,
$df_location) = split(/\|/, $_);

 $df_location;

 if ($df_showname == 0) {
  $df_name = "&nbsp;";
  $df_showemail = "0";
 }
 if ($df_showemail == 1) { $df_name = "<A
HREF=\"mailto:".$df_email."\">".$df_name."<\/A>"; }
 print "<TR>\n";
 print " <TD VALIGN=\"middle\"><FONT FACE=\"verdana,arial\"
SIZE=2>$df_name</FONT></TD>\n";
 print " <TD VALIGN=\"middle\"><FONT FACE=\"verdana,arial\"
SIZE=2>$df_callsign</FONT></TD>\n";
 print " <TD VALIGN=\"middle\"><FONT FACE=\"verdana,arial\"
SIZE=2>$df_location</FONT></TD>\n";
 print "</TR>\n";

Quote:
}

close FILE;

print qq~
</TABLE>
</P>
</CENTER>
</BODY></HTML>
~;

I tried the chomp function in both places to see if it made a
difference, and it didn't.  Here is the datafile:







Sat, 01 Feb 2003 09:49:48 GMT  
 CHOMP not working

Quote:

>Notice how the </FONT></TD> is on a new line?  Thats what I am trying to

Of course, you do realise that it doesn't make the slightest bit of
difference in HTML, multiple white spaces are folded into just 1 unless
you're inside <PRE> or <XMP> tags.

Quote:
>I tried the chomp function in both places to see if it made a
>difference, and it didn't.  Here is the datafile:






  # do header bit making the header/tables
  open(FH, "<datafile") || die "Content-Type: text/html\n\n Ack - $!";

  my($td_font) = '  <TD><FONT FACE="Verdana, Arial" SIZE=2>';
  my($font_td) = '</FONT></TD>';
  while(<FH>){

    print "<TR ALIGN=\"LEFT\">\n",

        "$td_font$4$font_td\n",
        "$td_font$5$font_td\n</TR>\n\n";
  }

or:
  while(<FH>){

    next if($#_ != 3); # for any spaces/broken lines
    $_[3] =~ s/\s+$//; # strip training CR/LF/space/fish
    print "<TR ALIGN=\"LEFT\">\n",
        "$td_font<A HREF=\"mailto:$_[1]\">$_[0]</A>$font_td\n",
        "$td_font$_[2]$font_td\n",
        "$td_font$_[3]$font_td\n</TR>\n\n";
  }

Cus its hot and I'm lazy :)
The ([^|]+) is because I've seen some weird stuff in people's call signs,
also note the \|'s because | in a regexp means to 'or', so a|b 'a' or 'b'
(which is why its such a pain that everyone uses it as a separating
character) Note also that this does *no* checking for validity of the data
(there is a .+ and [^|] in the regexp, so people can put dodgy code in
there+. (See, whoever it was that picked me up on this, I haven't
forgotten:)

Col.

---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC



Wed, 18 Jun 1902 08:00:00 GMT  
 CHOMP not working
THANK YOU!  Yea I knew that multiple white spaces are one, and that the
</FONT></TD> being on a second line doesn't do a thing to how its displayed,
just me being picky ;)

I was able to solve with just "$_[3] =~ s/\s+$//; # strip training
CR/LF/space/fish" part.  So it was one of those that was causing the problem.
Thank you alot.

*thought to self*
"Now that this half is done, now I have to set up the form processing script
that writes the info people enter into the file"  (ie, you'll probably being
hearing more from me)  ;)

Quote:


> >Notice how the </FONT></TD> is on a new line?  Thats what I am trying to

> Of course, you do realise that it doesn't make the slightest bit of
> difference in HTML, multiple white spaces are folded into just 1 unless
> you're inside <PRE> or <XMP> tags.

> >I tried the chomp function in both places to see if it made a
> >difference, and it didn't.  Here is the datafile:





>   # do header bit making the header/tables
>   open(FH, "<datafile") || die "Content-Type: text/html\n\n Ack - $!";

>   my($td_font) = '  <TD><FONT FACE="Verdana, Arial" SIZE=2>';
>   my($font_td) = '</FONT></TD>';
>   while(<FH>){

>     print "<TR ALIGN=\"LEFT\">\n",

>         "$td_font$4$font_td\n",
>         "$td_font$5$font_td\n</TR>\n\n";
>   }

> or:
>   while(<FH>){

>     next if($#_ != 3); # for any spaces/broken lines
>     $_[3] =~ s/\s+$//; # strip training CR/LF/space/fish
>     print "<TR ALIGN=\"LEFT\">\n",
>         "$td_font<A HREF=\"mailto:$_[1]\">$_[0]</A>$font_td\n",
>         "$td_font$_[2]$font_td\n",
>         "$td_font$_[3]$font_td\n</TR>\n\n";
>   }

> Cus its hot and I'm lazy :)
> The ([^|]+) is because I've seen some weird stuff in people's call signs,
> also note the \|'s because | in a regexp means to 'or', so a|b 'a' or 'b'
> (which is why its such a pain that everyone uses it as a separating
> character) Note also that this does *no* checking for validity of the data
> (there is a .+ and [^|] in the regexp, so people can put dodgy code in
> there+. (See, whoever it was that picked me up on this, I haven't
> forgotten:)

> Col.

> ---
> Colin Keith
> Systems Administrator
> Network Operations Team
> ClaraNET (UK) Ltd. NOC

--
Todd Eddy

http://www.vrillusions.com/


Sun, 02 Feb 2003 09:49:41 GMT  
 CHOMP not working

Quote:

>just me being picky ;)

That's cool.

Quote:
>I was able to solve with just "$_[3] =~ s/\s+$//; # strip training
>CR/LF/space/fish" part.  So it was one of those that was causing the problem.

I hope it wasn't the fish. They do get in odd places at times :))

Quote:
>"Now that this half is done, now I have to set up the form processing script
>that writes the info people enter into the file"  (ie, you'll probably being
>hearing more from me)  ;)

Then some tips:
 Don't trust the entered values. Ensure the name only contain letters.
Ensure the address only contain letters, numbers, comma, period and hyphen.
etc. The callsign should probably be allowed to contain anything. There are
people who use letters that don't match A-Za-z, but you should be okay if
you convert anything non alphanumeric to its HTML entity: &asc; where 'asc'
is its ASCII value. I'd ditch \0's and don't allow raw |. Also convert <, >
and & to their entities => (&lt; &gt; &amp;) so they can't be used to embed
something icky.

You can do all of this using s/// which is the only way to untaint  external
variables if you're using taint checking (-T when executing) See man perlsec
and I think CPAN and Perl.com have FAQ's/Tutorials on things to check
when writing CGI scripts but I don't have the URLs :)

Col.

---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. chomp not working

2. CHOMP not working on some servers

3. chomp not chomping w/ new $/ char

4. correction to previous post - chomp, not chop!

5. chomp not chomping?

6. Is chomp in perl 4 or not?

7. Send mail script not working in 2nd server but working in 1st server

8. Send mail script not working in 2nd server but working in 1st server

9. DBD::XBase 'not' not working

10. External DTD not working in XML::DOM ! (fwd)

11. Crypt() not working for me

12. Overloaded += not working from xsub

 

 
Powered by phpBB® Forum Software