
BillKSmith
Veteran
Sep 19, 2010, 2:41 PM
Post #2 of 4
(318 views)
|
|
Re: [yasdel] Check if txt file contains numbers
[In reply to]
|
Can't Post
|
|
I recommend using the function 'is_numeric' in the CPAN module Data::Validate to select the numbers for processing. use strict; use warnings; use Data::Validate qw(:math); foreach my $line (<DATA>) { chomp ($line); my @nums = split ' ', $line; foreach my $num (@nums) { $num *= 1.5 if is_numeric($num); } print "@nums\n"; } __END__ 0 700000 HR 700000 1300000 H3 1300000 2100000 H2 2100000 3800000 HH 3800000 4500000 HQ 4500000 5000000 HP 5000000 5700000 HO Edit: Simplified processing. Good Luck, Bill
(This post was edited by BillKSmith on Sep 20, 2010, 5:57 AM)
|