Perhaps I've totally missed the point, but if you want to add line numbers to your program, you could include this snippet in every program you write.
sub lines_count { open IN, "< $0" || die "Can't open file (black magic?)\n"; while( <IN> ) { chomp; printf "%3d: %s\n", $., $_; } close IN; }
So, you could type:

perl my_script.pl -e lines_count > something_that_let_you_print. (Maybe) Useful on system where wc does not exist.

Update Sorry, I've said something wrong. From perlrun...

-e commandline
may be used to enter one line of script. If -e is given, Perl will not look for a script filename in the argument list. Multiple -e commands may be given to build up a multi-line script. Make sure to use semicolons where you would in a normal program.
So what you could write is:

perl -e 'while (<>) {chomp; printf "%3d: %s\n", $., $_; }' < some_script > something_that_let_you_print

Sorry :)


In reply to Re: Line-counts of perl programs/modules by larsen
in thread Line-counts of perl programs/modules by Tarka

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.