Answers for "perl last characters"

1

perl last characters

# For Perl (language) only

# syntax
substr(<your-string>,-<characters-to-extract>)

# example 
substr("Glass half empty, glass half full",-15)

# application
my $sRandom = "Glass half empty, glass half full";
my $sLastFewChars = substr($sRandom,-15);
print "[ sRandom : '$sRandom' ] \n[ sLastFewChars : '$sLastFewChars' ]" . "\n";
Posted by: Guest on May-11-2020

Browse Popular Code Answers by Language