Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: loop to remove negatives

by Eliya (Vicar)
on May 14, 2012 at 19:14 UTC ( #970489=note: print w/replies, xml ) Need Help??


in reply to loop to remove negatives

Use the aliasing feature of for

for ($busi1, $busi2, $busi3) { s/-//g; }

I.e., the indidual items you loop over are being aliased to $_ in this case.

Or use an array instead of individual variables named $var1, $var2, ..., in which case the above would reduce to

for (@busi) { s/-//g; }

(But naturally, when you want to refer to a single value only in other places of your code, you'd then have to say, for example, $busi[2])

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970489]
help
Chatterbox?
[virtualsue]: 1nickt thatch repair just finishing
[virtualsue]: they've done enough to get it through winter
holli loves lightning talks
[1nickt]: ... but not the last straw?
1nickt ducks
virtualsue will be sweeping/raking it up for days
[virtualsue]: I need to get some cat pics into my talk http://www.cat- lovers-only.com/ images/three-cat- burritos-to-go-500 .jpg

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-11-21 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (300 votes). Check out past polls.

    Notices?