1*cdf0e10cSrcweirpackage stringhelper; 2*cdf0e10cSrcweir 3*cdf0e10cSrcweir#************************************************************************* 4*cdf0e10cSrcweir# 5*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6*cdf0e10cSrcweir# 7*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 8*cdf0e10cSrcweir# 9*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 10*cdf0e10cSrcweir# 11*cdf0e10cSrcweir# This file is part of OpenOffice.org. 12*cdf0e10cSrcweir# 13*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 14*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 15*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 16*cdf0e10cSrcweir# 17*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 18*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 19*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 21*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 22*cdf0e10cSrcweir# 23*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 24*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 25*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 26*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 27*cdf0e10cSrcweir# 28*cdf0e10cSrcweir#************************************************************************* 29*cdf0e10cSrcweir 30*cdf0e10cSrcweiruse strict; 31*cdf0e10cSrcweir 32*cdf0e10cSrcweirBEGIN { 33*cdf0e10cSrcweir use Exporter (); 34*cdf0e10cSrcweir our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir $VERSION = 1.00; 37*cdf0e10cSrcweir # if using RCS/CVS, this may be preferred 38*cdf0e10cSrcweir $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker 39*cdf0e10cSrcweir @ISA = qw(Exporter); 40*cdf0e10cSrcweir @EXPORT = qw(&endswith &startswith); 41*cdf0e10cSrcweir %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], 42*cdf0e10cSrcweir # your exported package globals go here, 43*cdf0e10cSrcweir # as well as any optionally exported functions 44*cdf0e10cSrcweir @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); 45*cdf0e10cSrcweir} 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir# string helper like java endsWith 48*cdf0e10cSrcweirsub endswith($$) 49*cdf0e10cSrcweir{ 50*cdf0e10cSrcweir my $string = shift; 51*cdf0e10cSrcweir my $search = shift; 52*cdf0e10cSrcweir if ( $string =~ /${search}$/ ) 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir return 1; 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir return 0; 57*cdf0e10cSrcweir} 58*cdf0e10cSrcweirsub startswith($$) 59*cdf0e10cSrcweir{ 60*cdf0e10cSrcweir my $string = shift; 61*cdf0e10cSrcweir my $search = shift; 62*cdf0e10cSrcweir if ( $string =~ /^${search}/ ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir return 1; 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir return 0; 67*cdf0e10cSrcweir} 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir1; 70