diff options
Diffstat (limited to 'MDK')
-rw-r--r-- | MDK/Common.pm.pl | 2 | ||||
-rw-r--r-- | MDK/Common/String.pm | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/MDK/Common.pm.pl b/MDK/Common.pm.pl index 2ac0e37..07198f5 100644 --- a/MDK/Common.pm.pl +++ b/MDK/Common.pm.pl @@ -74,7 +74,7 @@ use vars qw(@ISA @EXPORT $VERSION); #); # perl_checker: RE-EXPORT-ALL @EXPORT = map { @$_ } map { values %{'MDK::Common::' . $_ . 'EXPORT_TAGS'} } grep { /::$/ } keys %MDK::Common::; -$VERSION = "1.1.14"; +$VERSION = "1.1.15"; 1; EOF diff --git a/MDK/Common/String.pm b/MDK/Common/String.pm index 484ee2c..80c6598 100644 --- a/MDK/Common/String.pm +++ b/MDK/Common/String.pm @@ -42,6 +42,13 @@ remove "\n"s when the next line doesn't start with a space. Otherwise keep handle carriage return just like LaTeX: merge lines that are not separated by an empty line +=item begins_with(STRING, STRING) + +return true if first argument begins with the second argument. Use this +instead of regexps if you don't want regexps. + +begins_with("hello world", "hello") # => 1 + =item warp_text(STRING, INT) return a list of lines which do not exceed INT characters @@ -62,7 +69,7 @@ L<MDK::Common> use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK); @ISA = qw(Exporter); -@EXPORT_OK = qw(bestMatchSentence formatList formatError formatTimeRaw formatLines formatAlaTeX warp_text); +@EXPORT_OK = qw(bestMatchSentence formatList formatError formatTimeRaw formatLines formatAlaTeX begins_with warp_text); %EXPORT_TAGS = (all => [ @EXPORT_OK ]); @@ -128,7 +135,10 @@ sub formatAlaTeX { } - +sub begins_with { + my ($s, $prefix) = @_; + index($s, $prefix) == 0; +} sub warp_text { my ($text, $o_width) = @_; |