Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Samples of big projects done in Perl

by ForgotPasswordAgain (Priest)
on Aug 07, 2006 at 14:11 UTC ( [id://565949]=note: print w/replies, xml ) Need Help??


in reply to Re: Samples of big projects done in Perl
in thread Samples of big projects done in Perl

I don't think that's "big" big. You're probably not running a space shuttle or emacs or anything. It's beyond shell script size, though.

I'm aware of the "order of magnitude" argument mentioned elsewhere in this thread, saying that 1 line of Perl is like 10 lines of C. It sounds nice, but I'm not sure I really buy it. Since 1 line of Perl is 10 lines of C, assuming that's true in the first place, then in the Perl code you're freed to think at a higher level of abstraction. It's not as if you're juggling 10 times as much in each line of Perl code.

I think that argument is more for motivating people to write cleaner Perl code in the first place. "Should I put these 100 lines in a module?" "Would you put 1000 lines of C in a .c file?" "Sure." "Put your 100 Perl lines in a module, then." It seems to me to be more a way of determining at what size you want to start thinking about things at a higher level. But.. I mean if you're using a C library or a Perl module, it doesn't really matter how much code is inside them. They have (ideally) some external interface that you use, and that's it. Using 10 C libraries or 10 Perl modules, neither is substantially more complicated than the other, is it?

How many lines of code is Firefox, for example? How many lines would the equivalent implemented in Perl be? Would the Perl version be 10 times simpler? What if you included also the Perl modules it uses? Perl itself?

Using your shell command I found 190,000 lines in the latest release of Bricolage. But a lot of that is POD. Has anyone written a line counter with POD sections stripped out? (Maybe comments should also be removed; I'm not sure what exactly the definition of "line of code" is. On the other hand, Bricolage is a web application, so we should probably also include JavaScript, CSS, HTML, etc. as code.)

Replies are listed 'Best First'.
Re^3: Samples of big projects done in Perl
by hv (Prior) on Aug 08, 2006 at 10:32 UTC

    Has anyone written a line counter with POD sections stripped out?

    Here's the somewhat rough-and-ready code I use to count lines in my work application:

    #!/usr/bin/perl -w use strict; use File::Find; my($d, $c, $h, $q, $s, $x) = (0, 0, 0, 0, 0, 0); for my $dir (qw/ cgi lib util /) { find(sub { return if /^\.#/ || /,v$/ || /\.(swp|gif|jpg|png|ps|tr|o|a)$/ || / +~$/ || /^core$/; $File::Find::prune = 1, return if $File::Find::dir =~ /\bCVS\b/; return unless -f && -T; local *F; my $file = $_; open F, $file or warn "$File::Find::dir/$file: $!\n"; my $cut = 0; my $here = undef; my $where; while (<F>) { if ($cut) { ++$$where; $cut = 0 if $cut > 0 && /^=cut/; } elsif ($here) { ++$$where; $here = undef if /$here/; } elsif (/^=/) { ++$d; $cut = 1; $where = \$d; } elsif (!/\S/) { ++$s; } elsif (/^\s*#/) { ++$c; } elsif (/<<(?:'(\w+)'|(\w+))/) { my $style = $1 || $2; $where = ($style eq 'SQL') ? \$q : \$h; $here = qr/^$style$/; ++$x; } elsif (/^__(DATA|END)__$/) { $cut = -1; $where = \$h; } else { ++$x; } } }, $dir); } print "doc $d, comment $c, SQL $q, text $h, space $s, code $x\n";

    This currently reports: doc 5699, comment 1685, SQL 675, text 4295, space 4382, code 37030.

    Hugo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://565949]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-28 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found