Search notes:

Perl function: substr

#
#   substr EXPR, OFFSET, LENGTH, REPLACEMENT
#   substr EXPR, OFFSET, LENGTH
#   substr EXPR, OFFSET
#
use warnings;
use strict;

use feature 'say';

my $expr = '0123456789';

say substr($expr,  0,  4);           #   0123
say substr($expr,  5,  3);           #   567
say substr($expr,  7    );           #   789
say substr($expr, -4    );           #   6789
say substr($expr, -4,  2);           #   67
say substr($expr,  5, -2);           #   567
say substr($expr,  8, 20);           #   89

    substr($expr,  4,  3, "abc"); 
       say $expr;                    #   0123abc789
    substr($expr,  4,  3) = "456";
       say $expr;                    #   0123456789
Github repository about-perl, path: /functions/substr.pl

See also

Perl functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1739938338, '18.191.238.22', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/functions/substr(67): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78