in reply to cool way of manipulating array elements
Maybe map? and a util function to test for whether each element is a number - Scalar::Util?
use strict; use warnings; # or some other util function that can tell if it is a number... use Scalar::Util qw(looks_like_number); my @array = ('1','2','45','65','what is this?'); my @mod = map {if (looks_like_number($_)){$_*2} else {$_}} @array; print "$_\n" for @mod;
Hope this helps... (I am a bit Rusty, so be gentle...)
Just a something something...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: cool way of manipulating array elements
by pashanoid (Scribe) on Aug 30, 2011 at 08:18 UTC | |
by GrandFather (Saint) on Aug 30, 2011 at 10:06 UTC |
In Section
Seekers of Perl Wisdom