Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

\n error! ahhh!

Posted on 1998-12-23
5
Medium Priority
?
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:bkearns
ID: 1207148
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
ID: 1207149
There is no '\n' character anywhere in the string..the output is still produced this way.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1207150
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
ID: 1207151
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
ID: 1207152
Dunno if this will work but hell I just want closure.

One tough bug.

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Six Sigma Control Plans

647 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