1cdf0e10cSrcweirpackage stringhelper; 2cdf0e10cSrcweir 3*9780544fSAndrew Rist#************************************************************** 4*9780544fSAndrew Rist# 5*9780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 6*9780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 7*9780544fSAndrew Rist# distributed with this work for additional information 8*9780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 9*9780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 10*9780544fSAndrew Rist# "License"); you may not use this file except in compliance 11*9780544fSAndrew Rist# with the License. You may obtain a copy of the License at 12*9780544fSAndrew Rist# 13*9780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 14*9780544fSAndrew Rist# 15*9780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 16*9780544fSAndrew Rist# software distributed under the License is distributed on an 17*9780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18*9780544fSAndrew Rist# KIND, either express or implied. See the License for the 19*9780544fSAndrew Rist# specific language governing permissions and limitations 20*9780544fSAndrew Rist# under the License. 21*9780544fSAndrew Rist# 22*9780544fSAndrew Rist#************************************************************** 23*9780544fSAndrew Rist 24*9780544fSAndrew Rist 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse strict; 27cdf0e10cSrcweir 28cdf0e10cSrcweirBEGIN { 29cdf0e10cSrcweir use Exporter (); 30cdf0e10cSrcweir our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 31cdf0e10cSrcweir 32cdf0e10cSrcweir $VERSION = 1.00; 33cdf0e10cSrcweir # if using RCS/CVS, this may be preferred 34cdf0e10cSrcweir $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker 35cdf0e10cSrcweir @ISA = qw(Exporter); 36cdf0e10cSrcweir @EXPORT = qw(&endswith &startswith); 37cdf0e10cSrcweir %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], 38cdf0e10cSrcweir # your exported package globals go here, 39cdf0e10cSrcweir # as well as any optionally exported functions 40cdf0e10cSrcweir @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); 41cdf0e10cSrcweir} 42cdf0e10cSrcweir 43cdf0e10cSrcweir# string helper like java endsWith 44cdf0e10cSrcweirsub endswith($$) 45cdf0e10cSrcweir{ 46cdf0e10cSrcweir my $string = shift; 47cdf0e10cSrcweir my $search = shift; 48cdf0e10cSrcweir if ( $string =~ /${search}$/ ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir return 1; 51cdf0e10cSrcweir } 52cdf0e10cSrcweir return 0; 53cdf0e10cSrcweir} 54cdf0e10cSrcweirsub startswith($$) 55cdf0e10cSrcweir{ 56cdf0e10cSrcweir my $string = shift; 57cdf0e10cSrcweir my $search = shift; 58cdf0e10cSrcweir if ( $string =~ /^${search}/ ) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir return 1; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir return 0; 63cdf0e10cSrcweir} 64cdf0e10cSrcweir 65cdf0e10cSrcweir1; 66