Hi,

I have the following code:

print PC "$id|"; foreach $userdirective(@userdirectiveslist){ $hashref=$instdetails{$instnum}{$userdirective}; foreach $key(keys %$hashref){ print PC "$key"; ## last key value } print PC ','; }

which prints:

smpd300:/jr/patrol/ba/data/BA_AUDIT# cat smpd300_patrol.apache_misc.da +t smpd300_1|On, smpd300_2|On, smpd300_3|On, smpd300_4|On, ,mpd300_5|On smpd300_6|On, smpd300_7|Off,

It should print "smpd300_5|On," but for some reason the comma is appearing at the start of the line.

What's even more strange is, if I do a grep:

smpd300:/jr/patrol/ba/data/BA_AUDIT# grep smpd300_5 smpd300_patrol.apa +che_misc.dat ,mpd300_5|On smpd300:/jr/patrol/ba/data/BA_AUDIT#

it seems to filter out the line.

Does anyone know why this happens, and how to fix it?

Thanks,
js.

Found the problem. There seems to be a carriage return in there:

od -c smpd300_patrol.apache_misc.dat 0000000 s m p d 3 0 0 _ 1 | O n , \n s +m 0000020 p d 3 0 0 _ 2 | O n , \n s m p +d 0000040 3 0 0 _ 3 | O n , \n s m p d 3 +0 0000060 0 _ 4 | O n , \n s m p d 3 0 0 +_ 0000100 5 | O n \r , \n s m p d 3 0 0 _ +6 0000120 | O n , \n s m p d 3 0 0 _ 7 | +O 0000140 f f , \n 0000144

In reply to print problem by js1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.