Site menu:

Back to examples

Perl Example - Greedy Matching

#################################################
#Version 0.1                                    #
#Free to use for any purpose                    #
#No credits or backlink required                #
#Author : Shaji Kalidasan (shajiindia@yahoo.com)#
#################################################
use 5.010;
use strict;
use warnings;

#Greedy matching
while(<DATA>) {
	if(/Betty (.*) butter/) {
	    say $1;
	}
}

__DATA__
Betty bought some butter the butter was bitter so she bought some better butter to make the bitter butter better.