Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Strange characters encountered in refactoring perl program

by redhotpenguin (Deacon)
on Feb 17, 2005 at 06:21 UTC ( [id://431848]=perlquestion: print w/replies, xml ) Need Help??

redhotpenguin has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks,

I have spent the past couple hours banging my head up against this problem. I was refactoring a perl program I downloaded to generate visual diagrams from a database, and introduced Pod::Usage into the mix to clean things up. When it didn't work for verbosity levels 0 and 1, but worked for verbosity level 2, I made a copy of the original file, and then stripped out everything except the pod, and the Pod::Usage code. Convinced I was inept or losing my mind, I tried it with different perls, and different platforms, and still the problem persisted.

As a last ditch effort I opened up a new text editor, copied the contents into the editor, and saved the file. Lo and behold it worked! Upon using the system command 'ls -al' to inspect both files, I found that the original file was 16 bytes larger, so something is in there but is not showing up in my vi editor.

Stepping through the calls to Pod::Usage with the perl debugger lead me to Pod::Parser line 1067:

$textline = $self->preprocess_line($textline, ++$nlines);

The original file $textline contained "#!/usr/bin/perl\cM\cJ", while the copy I created had the expected "#!/usr/bin/perl". Every line in the original file had that '\cM\cJ' string appended to each line. I've dealt with CRLF problems before, but what kind of control characters are these (if that's what they are), and why is it that I could only find them using the perl debugger?

Thanks in advance for any advice, and read more for the content of the program I ended up with before stepping into the debugger.

#!/usr/bin/perl use strict; use warnings; use Pod::Usage; pod2usage(-verbose => 1, -exitval => 1); 1; __END__ =head1 NAME mysql2dia =head1 SYNOPSIS mysql2dia =head1 OPTIONS =over 8 =item B<--help> Generate this usage message and exit. =back =cut

Replies are listed 'Best First'.
Re: Strange characters encountered in refactoring perl program
by dws (Chancellor) on Feb 17, 2005 at 06:27 UTC

    I've dealt with CRLF problems before, but what kind of control characters are these (if that's what they are), and why is it that I could only find them using the perl debugger?

    You have encountered CRLF in one of their many disguises. \cM is ^M is <CR>, and \cJ is ^J is <LF>.

    As to why you're not seeing them in your editor, I dunno. Does your editor have a setting for showing control characters?

      Thanks for responding. vim -b did the trick. The strange behavior from Pod::Usage threw me for a loop. I've gotten used to <CR>'s in their \r form.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://431848]
Approved by NetWallah
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found