in reply to string functions

Hi valavanp, Try like this,

use strict; use warnings; my $str = "2A2B2C"; my %p = (A => 1.5, B => 2.5, C => 3.5); my @arr = split/(?=\d+)/, $str; my $range = 50; map{s/^(\d+)([^\d]+)$/(($p{$2}."\*") x $1)."$range\/100"/e; $range+=5; +}@arr; $str = eval join'*', @arr; print $str;

Updated
valavanp, see below for The range is (50,55,60,65,70,75,80,85,90). How can i code that. your solutions.

use strict; use warnings; my $str = "2A2B2C"; my %p = (A => 1.5, B => 2.5, C => 3.5); my @arr = split/(?=\d+)/, $str; my @range = (50,55,60,65,70,75,80,85,90); my $i =0; map{s/^(\d+)([^\d]+)$/(($p{$2}."\*") x $1)."$range[$i]\/100"/e; $i++;} +@arr; $str = eval join'*', @arr; print $str;

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.