[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Trying to add products using non-numeric quantities...
* Jeff Carnahan wrote on Wed, Jun 27, 2001 at 22:41 -0700:
> @quantities = map { if (/^=/) { s/\D//g; '=' . $_ } else { s/\D//g; $_ } }
>
> Note my ugly use of an if statement to keep the equals sign
> necessary for the $set flag later, if there is a better way to
> do this, please let me know
You want this w/o the if? I think you can write:
> @quantities = map { if (/^=/) { s/\D//g; '=' . $_ } else { s/\D//g; $_ } }
@quantities = map { s/(^=)?\D/$1/g; $_ }
or better:
@quantities = map { s/[^\d=]//g; $_ }
or maybe faster like:
#delete unknown (==not 0-9,=) chars and map something(?):
@quantities = map { tr/0-9=//cd; $_ }
all this is untested, and my perl will not even compile your
original expression, which I do not understand BTW, since I
though that map should get some list as second argument (to map
that list), so this seems to be some special usage of map or
whatever. :)
oki,
Steffen
--
Dieses Schreiben wurde maschinell erstellt,
es trägt daher weder Unterschrift noch Siegel.