I am having some trouble reading a file using Activestate perl.
I have a ".csv" file that was emailed to me.
It opens fine in Excel. It opens fine in Notepad,
tho it seems tab delimited (despite the file name),
and the eol chars show in notepad as empty boxes and the file is run onto one line.
Fine -- at this point, I am thinking it is a tab delim file and I need to adjust unix/win line endings.
When I read it in with perl, however, and print the 1st line, I get an extra space after each char:
my $fh = FileHandle->new($file) or die "cannot read open $file";
my $row = <$fh>;
print "|$row|\n";
yields something like this
| !D A I L Y R E P O R T
|
where the "!" denotes a black box. When I look at the file in Notepad or Excel, the first line is "DAILY REPORT", not
"D A I L Y R E P O R T"
Where are the extra spaces coming from?
Thanks
rkg
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.