diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-08-02 04:48:58 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-08-02 04:48:58 +0000 |
commit | 2b9fcc72ed97ec345a0769817e13379a98a02862 (patch) | |
tree | 96f94ae289330dee7e4be2c17bd4cd3ef9b6ffbd /MDK/Common/String.pm | |
parent | 4eb86f480428513e47aeeb97d671bbffba6daa14 (diff) | |
download | perl-MDK-Common-2b9fcc72ed97ec345a0769817e13379a98a02862.tar perl-MDK-Common-2b9fcc72ed97ec345a0769817e13379a98a02862.tar.gz perl-MDK-Common-2b9fcc72ed97ec345a0769817e13379a98a02862.tar.bz2 perl-MDK-Common-2b9fcc72ed97ec345a0769817e13379a98a02862.tar.xz perl-MDK-Common-2b9fcc72ed97ec345a0769817e13379a98a02862.zip |
- workaround bug in ocaml on ultrasparc
(can't catch exception "Fatal error: out-of-bound access in array or string" in native code)
- add begins_with in MDK::Common::String
Diffstat (limited to 'MDK/Common/String.pm')
-rw-r--r-- | MDK/Common/String.pm | 14 |
1 files changed, 12 insertions, 2 deletions
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) = @_; |