in reply to Line-counts of perl programs/modules
So, you could type:sub lines_count { open IN, "< $0" || die "Can't open file (black magic?)\n"; while( <IN> ) { chomp; printf "%3d: %s\n", $., $_; } close IN; }
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 commandlineSo what you could write is:
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.
perl -e 'while (<>) {chomp; printf "%3d: %s\n", $., $_; }' < some_script > something_that_let_you_print
Sorry :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Line-counts of perl programs/modules
by snafu (Chaplain) on Apr 27, 2001 at 17:31 UTC | |
|
Re: Re: Line-counts of perl programs/modules
by knobunc (Pilgrim) on Apr 27, 2001 at 18:33 UTC |