Search notes:

Perl substitution: e flag

use warnings;
use strict;

my $string;

$string = "20 22";
$string =~ s/(\d+) (\d+)/$1 + $2/e;
print "$string\n";
# 42

$string = "hello world";
$string =~ s/(\w+) (\w+)/$1 . '-' . $2/e;
print "$string\n";
# hello-world

$string = "'hello' . ' ' . 'world'";
$string =~s/(.*)/$1/e;
print "$string\n";
# 'hello' . ' ' . 'world'

$string = "'hello' . ' ' . 'world'";
$string =~ s/(.*)/eval($1)/e;
print "$string\n";
# hello world

$string = "'hello' . ' ' . 'world'";
$string =~ s/(.*)/$1/ee;
print "$string\n";
# hello world
Github repository about-perl, path: /functions/s__e.pl

See also

Perl function: s (substitute)
Perl substitution: replace and assign
Perl: regular expression to substitute within matched region
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...', 1758207258, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/functions/s__e(75): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78