#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11158577 use warnings; for ( split /\n/, <## found 'foo' in '#foo bli bla' found 'foo' in 'bli #foo bar baz' found 'more' in '#more than #one is a #string' found 'one' in 'more than #one is a #string' found '' in 'foo bli bla' found '' in '# does not match #'