in reply to String substitution
Please give some more example lines.#!/usr/bin/perl use strict; use warnings; my $str = 'hello nr34 , 56, hi'; print "input string=$str\n"; $str =~ s/.*nr(\d+)([^\d]+)(\d+)(.*)/"calc(nr$1)$2".eval{$3*4}."$4";/e +; print "output string=$str\n"; __END__ Prints: input string=hello nr34 , 56, hi output string=calc(nr34) , 224, hi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: String substitution
by AnomalousMonk (Archbishop) on Sep 20, 2016 at 02:56 UTC |