perl_devel has asked for the wisdom of the Perl Monks concerning the following question:
I overcame a problem which displays warnings while executing perl program, the situation is
In the above case the $param may be a string or integer and in case if it is a integer then, we will usually get a warning saying cannot do a string comparison for the integer value .sub compare{ $param=shift; print "String" if($param eq "5"); }
so can this be avoided ,is there a way to check if $param is integer of string and based on that do a string or integer comparison? Like we do a check for Ref("ARRRAY")?
Regards
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Handling both string and numeric comparisons
by holli (Abbot) on May 12, 2005 at 13:00 UTC | |
|
Re: Handling both string and numeric comparisons
by rob_au (Abbot) on May 12, 2005 at 11:31 UTC | |
by Roy Johnson (Monsignor) on May 12, 2005 at 12:01 UTC | |
|
Re: Handling both string and numeric comparisons
by thcsoft (Monk) on May 12, 2005 at 11:34 UTC | |
by chromatic (Archbishop) on May 12, 2005 at 14:58 UTC | |
|
Re: Handling both string and numeric comparisons
by Aragorn (Curate) on May 12, 2005 at 14:44 UTC | |
|
Re: Handling both string and numeric comparisons
by starbolin (Hermit) on May 12, 2005 at 17:45 UTC |