in reply to Re: cool way of manipulating array elements
in thread cool way of manipulating array elements
print map {( $_ =~ /^-?\d+$/ ? $_ * 2 : '-' ),"\n"} @array;
You could try something like this to catch integers.
print map {( $_ =~ /^-?(\d*\.)?\d+$/ ? $_ * 2 : '-' ),"\n"} @array;
Or something like this to catch numbers with decimals. Both of these will simply ignore leading zeros as perl is apt to do when converting strings to numbers.
|
|---|