Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- parse newline
February 8, 2009, 9:05 am
rate this thread
10, 13, I just don't know why some newlines are printed. As the file is
generated by another program, I cannot see the source code, and manual
inspection does not discover any abnormalty.
using chop, chomp or to use replace cannot help. Does anybody have
experience in handling this?
Re: parse newline
What character set are you using? None of the common ASCII-based
character sets (WIndows-1252, ISO-Latin-xxx, Unicode, ...) has a newline
character. See also below.
Apparently you've never read The Hitchhikers Guide through the Galaxy.
Long form: how do you propose us to fix your code without seeing it?
Have you seen the posting guidelines that are posted here twice a week?
This will remove the last character of $identiy.
How do you know that last character is actually the newline?
This will remove a trailing $/ from $identiy, whatever $/ may be set to
on your system (usually "\n").
Did you check that $/ matches the tail of $identiy?
This looks identical to the first line?
This is working on $identity instead of $identiy. Is that what you meant
One common problem are format incompatibilities between Windows, Mac,
and Unix. They use different characters/character combinations to denote
a line break. Therefore you should be very explicit about if you are
talking about a line feed character(LF), a carriage return
character(CR), or a logical newline entity of your OS.
Aside of that I suspect that you are looking at the wrong spot and your
real problem is somewhere else, like e.g. a misspelled variable name as
As strongly suggested in the posting guidelines please post a
self-contained, minimal program that demonstrates your problem, in your
case including some sample input data, preferable as a _DATA_ section.
Re: parse newline
You might be encountering NUL characters. I run into the NUL character
problem when working with Windows event logs. Try to use the following on
your data: =~ s//\t/g; You can change "\t" to whatever you need.
# Get event data
my $streaingTest = $Event;
# Change NUL to tab for event data
$streaingTest =~ s//\t/g;
- » FAQ 4.69 How can I make the Perl equivalent of a C structure/C++ class/hash or array of ha...
- — Previous thread in » PERL Discussions