Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Substr Problem

by GrandFather (Sage)
on Sep 27, 2012 at 01:38 UTC ( #995901=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
Re^2: Substr Problem
by snape (Pilgrim) on Sep 27, 2012 at 01:43 UTC

    Thanks a lot. The mistake I was doing was my thinking in the substr way ro solve my problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995901]
help
Chatterbox?
[Discipulus]: I read an article about how much the female condition has got worst in the eastern europe after the fall of social policies
LanX has a friend in Berlin who switched to go(lang) and just got a kid ...
[marto]: good morning all
[Corion]: Hi marto ;)
[Discipulus]: Corion ah! you opened a new search path! thanks
[choroba]: LanX No, but they grow and want more!
LanX was conditioned by a female
Discipulus my 'kids' always complain with our car..
[LanX]: true, cars are bad in growing
[marto]: WaitWindow()

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2017-01-17 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (154 votes). Check out past polls.