[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Perl Filter Demos?



>I would love to have some intriguing demo filters on hand at WWDC (the
>Apple World Wide Developers Conference) in a week or so.  They should
>have a strong "Gee Whiz!" factor.  It would also be nice if they can
>be explained to mortal programmers...

Hi, This one i use quite often,
maybe the syntax isn't that clean, but it works.
It checks to see if there are double lines in the selection,
right obove each other. If there is, the last one is deleted.

In fact every line is written back exept when the last one 
was identical.

Hope this helps?

Cheers, Tommy.

#!perl -w

$last ="str";                      #  just some phony init.

while( @string = <> )              # as long as there is input
{
	foreach $string (@string)         # for every line in the inputbuffer
	{
		if($string eq $last)             # if the line is equal to the last one
	{	    
	}                                 # do nothing
	else
	{
		   print "$string";              # else write the line back.
		   $last = $string ;             # and put a new string in the variable 
last.
	}	
}	



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org