#! perl -slw use strict; # my %hash = ...; my $str = 'Hi this is the sample string for string search'; my @words = split ' ', $str; for my $start ( 0 .. $#words - 1 ) { for my $end ( $start .. $#words ) { print "Lookup: ", join ' ', @words[ $start .. $end ]; } } __END__ C:\test>1001794 Lookup: Hi Lookup: Hi this Lookup: Hi this is Lookup: Hi this is the Lookup: Hi this is the sample Lookup: Hi this is the sample string Lookup: Hi this is the sample string for Lookup: Hi this is the sample string for string Lookup: Hi this is the sample string for string search Lookup: this Lookup: this is Lookup: this is the Lookup: this is the sample Lookup: this is the sample string Lookup: this is the sample string for Lookup: this is the sample string for string Lookup: this is the sample string for string search Lookup: is Lookup: is the Lookup: is the sample Lookup: is the sample string Lookup: is the sample string for Lookup: is the sample string for string Lookup: is the sample string for string search Lookup: the Lookup: the sample Lookup: the sample string Lookup: the sample string for Lookup: the sample string for string Lookup: the sample string for string search Lookup: sample Lookup: sample string Lookup: sample string for Lookup: sample string for string Lookup: sample string for string search Lookup: string Lookup: string for Lookup: string for string Lookup: string for string search Lookup: for Lookup: for string Lookup: for string search Lookup: string Lookup: string search