Perl Get First Characters

[Solved] Perl Get First Characters | Perl - Code Explorer | yomemimo.com
Question : perl get first characters

Answered by : jacques-kirstein

# For Perl (language) only
# syntax
substr(<your-string>,0,<characters-to-extract>)
# example
substr("Cool, isn't it!",0,4)
# application
my $sRandom = "Cool, isn't it!";
my $s1stFewChars = substr($sRandom,0,4);
print "[ sRandom : '$sRandom' ] \n[ s1stFewChars : '$s1stFewChars' ]" . "\n";

Source : | Last Update : Mon, 18 May 20

Answers related to perl get first characters

Code Explorer Popular Question For Perl