#!/usr/bin/perl use strict; use warnings; read DATA, my $text, 40; ### this is the important line ### my $wordcount = () = $text =~ /test/gi; print $wordcount; __DATA__ TEST tester testing asdf lalala greatest