Perl Requires Chilkat v9.5.0.87+
Chilkat2 Perl
Get a Substring by Char Index and Length
Demonstrates how to use the GetRange method to get a substring by index and length.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $sb = Chilkat2::StringBuilder->new;
# Load a file that contains this string: 0123456789ABCDEF
my $success = $sb->LoadFile('qa_data/txt/remove_chars.txt', 'utf-8');
# Return "56789A" from the string.
# if removeFlag is 1, the returned string is also removed from the sb.
my $removeFlag = 1;
my $result = $sb->GetRange(5, 6, $removeFlag);
print $result, "\n";
print $sb->GetAsString(), "\n";
# Output is:
#
# 56789A
# 01234BCDEF