[comp.lang.perl] writing subroutine filters

trygg@nososl.UUCP (Trygg A. Eliassen) (10/05/90)

We just got perl 3.0-28 this week and I read the man pages and started out to
write my first script : read a file with filenames, C-files and count 
all codelines but skip comments.

I made 2 scripts, the first loops on the filenames and pipes the contents
to another perl script to remove comments and further to wc to count the
characters.  This worked, but wouldn't it be better to make a subroutine
of the second script, to remove the comments.  I wouldn't have to start
a new perl script for each file.  I tried, but had to give up.

The nearest I got, was that I opened a pipe to wc and from the filter
I piped the output there, but then I never managed to get hold of the wc
output.

So !
	Can somebody give me an example of a subroutine that gets input
	filters it and returns the result so that the main body can continue
	processing on the data eg send it to new filters etc.

	Thanks
-- 
Trygg A. Eliassen BSc. Hons | trygg@nordic-offshore.no
Nordic Offshore Systems A.S | mcsun!nuug!nososl!trygg
Stabekk - Oslo - NORWAY     | Tlf +472 12 55 80  Fax +472 12 54 01