GertMT has asked for the wisdom of the Perl Monks concerning the following question:
I remain having the problem that I frequently get the message:#!/usr/bin/perl -w # use warnings use strict; use diagnostics;
oruse Data::Table; $joinTable->colsMap( sub { $_->[4] = skipblanks( $_->[4] ) } ); sub skipblanks { my @data = @_; my $x = 0; foreach $x (@data) { if ($x) { $x =~ s/,/\./g; } return $x; } }
use Data::Table; $joinTable->colsMap( sub { $_->[4] = to_int_or_zero( $_->[4] ) } ); sub to_int_or_zero { my $value = shift; if ( defined($value) && ( $value =~ m/^\d+$/ || $value =~ m/^-?\d+\.?d*$/ ) ) { return $value; } else { return 0; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: avoid uninitialized values for $_
by lima1 (Curate) on Nov 06, 2007 at 12:34 UTC | |
by GertMT (Hermit) on Nov 06, 2007 at 12:51 UTC |