Solved

\n error! ahhh!

Posted on 1998-12-23
5
167 Views
Last Modified: 2010-03-05
#!/usr/bin/perl

use Barecgi;
%formdata = Barecgi::parse_form();

$formdata{lname} = "Aratsu";
$requested_doctor_lname = $formdata{lname};

if($formdata{lname})
{

      $do_doctor_lname = 1;
      $found = 0;

      open(file, "data/tx/alias.doctors.ref");
      @alias_doctor_ref_fdata = <file>;
      chop(@alias_doctor_ref_fdata);
      close(file);

      for($f = 0; $alias_doctor_ref_fdata[$f]; $f = $f + 1)
      {

            open(file, "data/tx/usr/$alias_doctor_ref_fdata[$f]") or print "Error";
            @doctor_fdata = <file>;
            chop(@doctor_fdata);
            close(file);
            
            print "$doctor_fdata[0]\n";

            ($doctor_info_fname, $doctor_info_lname) = split(/!~~~!/, $doctor_fdata[0]);

            print "$doctor_info_fname - $doctor_info_lname\n";

            print "[matching] $requested_doctor_lname $doctor_info_lname";

            if($requested_doctor_lname eq $doctor_info_lname)
            {                                    
                  $found_doctor_lname[$found] = $alias_doctor_ref_fdata[$f];
                  $found = $found + 1;

            }                        

      }

}

When I run this, the output I get is (among other things):

[matching] aratsu
aratsu

Why is there a line break there?  There isn't one in the print statement.  

print "[matching] $requested_doctor_lname $doctor_info_lname";

$requested_doctor_lname is "Aratsu", so is $doctor_info_lname.  Chop either one of them and you get Arats.

What's up with this?

Tribal
0
Comment
Question by:tribal9
5 Comments
 

Expert Comment

by:bkearns
Comment Utility
You should try using chomp it is a safer version of chop, it only removes \n if it is there. Perhaps this will solve your problem.  
0
 

Author Comment

by:tribal9
Comment Utility
There is no '\n' character anywhere in the string..the output is still produced this way.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Where is the output going?
Is that really the output you get?  lower case "A" and no space after the line break?  Is there a space before the line break?
0
 
LVL 1

Accepted Solution

by:
sdjjm earned 0 total points
Comment Utility
Is an ASCII 13 the leading character on your second string?
Open a file and output your print statement into it.  Send both strings there individually and together.  View the file in binary mode and find out exactly where the bad character you don't want is located so you can deal with it accordingly.
0
 

Author Comment

by:tribal9
Comment Utility
Dunno if this will work but hell I just want closure.

One tough bug.

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now