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


in reply to Substr Problem

It's not over clear what you want to do, but my best guess is that you have a vector of data where you want to alter some of the values then print the resulting vector. A good way to do that is to transform your string representation of the data to an array, edit the data in the array, then write it back out as a string:

use strict; use warnings; use 5.010; my $str = "0\t" x 10; my @values = split '\s+', $str; printf "First statement:\t%s\n", join "\t", @values; @values[2, 3] = (0.5, 0.845); printf "Second statement:\t%s\n", join "\t", @values;

Prints:

First statement: 0 0 0 0 0 0 0 0 0 0 Second statement: 0 0 0.5 0.845 0 0 0 0 0 + 0
True laziness is hard work