U
Ulrich Herbst
Hi,
I have to substitute multiple patterns in a template with different
values.
Something like that:
----------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $template='a##1b##2c##3';
my $var1='x';
my $var2='y';
my $var3='z';
(my $newvar = $template) =~ s/##1/$var1/g;
$newvar =~ s/##2/$var2/g;
$newvar =~ s/##3/$var3/g;
print $newvar ."\n";
# $newvar = 'axbycz'
----------------------------------------------------------------------
Can I put these three lines with "s/.../.../" in one line ?
Uli
--
'''
(0 0)
+------oOO----(_)--------------+
| |
| Ulrich Herbst |
| |
+-------------------oOO--------+
|__|__|
|| ||
ooO Ooo
I have to substitute multiple patterns in a template with different
values.
Something like that:
----------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $template='a##1b##2c##3';
my $var1='x';
my $var2='y';
my $var3='z';
(my $newvar = $template) =~ s/##1/$var1/g;
$newvar =~ s/##2/$var2/g;
$newvar =~ s/##3/$var3/g;
print $newvar ."\n";
# $newvar = 'axbycz'
----------------------------------------------------------------------
Can I put these three lines with "s/.../.../" in one line ?
Uli
--
'''
(0 0)
+------oOO----(_)--------------+
| |
| Ulrich Herbst |
| |
+-------------------oOO--------+
|__|__|
|| ||
ooO Ooo