http://www.perlmonks.org?node_id=995906


in reply to Substr Problem

Hello snape,

GrandFather’s solution is definitely the way to go. However, for the record, your code can be made to give the output you want by changing the substitution:

substr($VALUE, 2, 2) =~ s/0/$signal/g;

into a simple assignment:

substr($VALUE, 2, 3) = $signal;

By the way, the /g modifier on the substitution is redundant in this case.

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re^2: Substr Problem
by choroba (Cardinal) on Sep 27, 2012 at 08:32 UTC
    Or, even simpler:
    substr $VALUE, 2, 3, $signal;
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ