Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: String manipulation

by tachyon (Chancellor)
on Aug 01, 2004 at 13:57 UTC ( [id://379070]=note: print w/replies, xml ) Need Help??


in reply to String manipulation

Well given that your posted code does not work (does not compile and is logically incorrect), this is similar, efficient and working:

$initValue = 2; $step = 3; $numOfMembers = 5; $str = '2 5 8 11 14'; my $str = $initValue; for my $member (1..$numOfMembers-1) { $str .= ' ' . ($initValue + $member*$step); } print $str, $/; $str = join ' ', map{ $initValue+$step*$_ } 0..$numOfMembers-1; print $str, $/;

cheers

tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379070]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found