cc => sub { "this is an amazingly long string" =~ /\s([^l]*)l/ }, ds => sub { "this is an amazingly long string" =~ /\s(.*?)l/ }, #### #!/usr/bin/perl -w use strict; my %data; while(){ next unless m/^(.*?):(.*?):A/; # non-greedy DS #next unless m/^([^:]*):([^:]*):A/; # negated CC $data{$1} = $2; } while( my($k,$v) = each %data) { print "$k => $v\n"; } __DATA__ abc:123:A:B def:456:A:C ghi:789:B:A jkl:000:C:C OUTPUT: non-greedy DS: abc => 123 def => 456 ghi => 789:B negated CC: abc => 123 def => 456 #### [1] well 'any character' except a newline, unless /s