Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: loop to remove negatives

by dsheroh (Prior)
on May 15, 2012 at 09:53 UTC ( #970588=note: print w/replies, xml ) Need Help??


in reply to Re: loop to remove negatives
in thread loop to remove negatives

The code given in the OP would work fine, provided that all the values are in an array (@busi). If they're independent scalars ($busi1, $busi2, etc., as in the example of what currently works), then it won't.

BluGeni, I strongly recommend putting your values into an array, then using

for (@busi) { $_ =~ s/-//g; }
(or, more idiomatically, s/-//g for @busi;) instead of working with the variables as independent scalars - any time you have a series of variables named $foo1, $foo2,..., that's a pretty strong indication that what you really want is an array.

If you need help getting these values into an array, just show us the code that you're currently using to assign their values and we can show you how to modify it to use an array instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970588]
help
Chatterbox?
[erix]: which still manages to sound more or less positive
[Corion]: Huh. I wasn't aware that you cannot segregate Python 2 and Python 3 modules... Hopefully Perl 6 module use C6AN and thus avoid the problem...
[hippo]: I very much hope so.
[moritz]: there are already some (very few) Perl 6 modules on CPAN, but in a way that the p5 indexer avoids them
[hippo]: It's confusing enough to have the Perl6:: namespace which isn't for Perl6 but for features from that ported into Perl.

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




    Results (203 votes). Check out past polls.