in reply to Re^2: Print left-anchored similarities between two strings
in thread Print left-anchored similarities between two strings
# our $input is user inputted string # and I only want directory/ names our @matches = map { -d $_? $_ .="/" : "" } <$input*>; expand_match || print "\a"; sub expand_match { return $input = $matches[0] if(@matches == 1); # Get the longest matching string from all elements my $match = $matches[0]; for (@matches) { $match = substr $_, 0, ( $match ^ $_ ) =~ /^\0*/ && $+[0]; } return $input = $match if length($match) > length($input); return 0; }
|
|---|