Solved

\n error! ahhh!

Posted on 1998-12-23
5
169 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl script 4 98
cpan issue 1 61
Bash one liner, start and end time calculation 13 103
quoting a comma separated list 20 83
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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

19 Experts available now in Live!

Get 1:1 Help Now