Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

.pm Files

by carlriz (Beadle)
on Mar 27, 2014 at 19:47 UTC ( #1079987=perlquestion: print w/replies, xml ) Need Help??
carlriz has asked for the wisdom of the Perl Monks concerning the following question:

I installed a new module on my computer today and while looking at the output of the CPAN installation script, I was curious at what .pm files looked like opened. Now, what I saw did not make sense to me. It is unreadable.

.tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo +10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo +12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode trans +form. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\"

This is just a snippet. What do those cryptic symbols mean?

Replies are listed 'Best First'.
Re: .pm Files
by kcott (Chancellor) on Mar 27, 2014 at 20:27 UTC

    G'day carlriz,

    If you'd actually named the Perl module, I could provide a more specific answer.

    A Perl module is written in Perl. This is not what you're looking at. As an example, look at the source code for Data::Dumper (which I just picked at random).

    What you've posted is the source code used to generate a manpage. The equivalent code for Data::Dumper starts like this:

    .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ================================================================== +====== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 ..

    As you can see on the first line, this is "generated by Pod::Man". See the Pod::Man documentation for more information (if you're still interested).

    -- Ken

      'Perl library for parsing text in the Pod ("plain old documentation") markup language that is typically used for writing documentation for Perl and for Perl modules'

      I see.

Re: .pm Files
by ww (Archbishop) on Mar 27, 2014 at 20:24 UTC

    I would agree that it's not easily comprehended... but "unreadable?" Well, not exactly. There are a lot of hints in the plain-text we can see; hints suggesting some sort of print-oriented device or operation.

    But your actual question is harder to answer, based on what you've told us

    The tool wich which you opened your .pm file with might make a difference -- among other things, in whether this is a typical extract; the entire content of the module; or an intermittent sample, in which the program that opened the file merely threw away characters that weren't in its vocabulary.

    So, please tell us: was it a hex editor; a text editor that will (I don't see any examples here) render certain non-ASCII characters as boxes (and perhaps etc) any editor that quits on anything it takes to be EOF; a debugger? And, not just BTW, in what OS did you open it?

    Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
    1. code
    2. verbatim error and/or warning messages
    3. a coherent explanation of what "doesn't work actually means.

      Operating System is OS X 10.8.4. And, I opened the file using emacs, a text editor.

Re: .pm Files
by davido (Archbishop) on Mar 27, 2014 at 20:39 UTC

    Keep in mind that a .pm file is usually a module, written in pure Perl. If the specific snippet you're looking at through a drinking straw is incomprehensible, try looking through a little bit wider peephole, and you will find Perl.


Re: .pm Files (.pm is just extension)
by Anonymous Monk on Mar 27, 2014 at 20:12 UTC

    What do those cryptic symbols mean?

    it depends, what module did you find that in?

      This is where I found them: File::HomeDir::Test.3pm.

        "This is where I found them: File::HomeDir::Test.3pm."

        Note the extension: ".3pm" not ".pm".

        Also note the double colons (::) in the file name. The filename for File::HomeDir::Test will be just ''. The pathname to the file will end with 'File/HomeDir/'.

        -- Ken

        That's the man page (ie. documentation), so the language is probably nroff.

        Try file ....3pm and see what it tells you

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1079987]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2017-05-29 12:00 GMT
Find Nodes?
    Voting Booth?