To remove the first N characters of a string in Perl, you can use substr function starting from index N.
In this example,
\$str1
with a value of "Hello World"
.\$str1 = "Hello World";
\$modified_str = substr(\$str1, 3);
print "Modified string is: \$modified_str\n";
Modified string is: lo World
In this example,
\$str2
with a value of "apple"
.\$str2 = "apple";
\$modified_str = substr(\$str2, 2);
print "Modified string is: \$modified_str\n";
Modified string is: ple
In this tutorial, we learned How to Remove first N Characters in a String in Perl language with well detailed examples.