Greetings, ye Monks of Perl.

I'm writing something that does a lot of readlink calls, and sometimes it returns some pretty strange stuff. I'm guessing the strangeness is actually coming from my operating system, but I wanted to share and see what you all thought.

Sometimes the returned string contains some non-printing characters followed by a bunch of pretty random looking stuff. Here's an example:

/proc/32433/exe -> /usr/bin/perl.pid]o_ff.jpg (deleted)

If I pipe that through less, I get to see markers showing me where the non-printing characters are:

/proc/32433/exe -> /usr/bin/perl^@.pid^@]^@^@o_ff.jpg (deleted)

An ordinary ls -l /proc/32433/exe says /proc/32433/exe -> /usr/bin/perl. I get the same by running the readlink command (/usr/bin/readlink).

So it looks like the correct answer followed by a bunch of other stuff.

If you're on linux, you can try this...

find /proc -type l -name 'exe' | \ perl -n -e 'chomp($_); print "$_ -> ".readlink($_)."\n";'
... and you might see what I'm talking about.

Anybody know what's going on here?

I'm on CentOS 5.5 running perl 5.8.8 from the perl-5.8.8-32.el5_5.1 rpm package.

Thanks!

--Pileofrogs


In reply to readlink returning strange stuff by pileofrogs

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.