Ulrich Holeschak wrote:

> Why i need to get the data type has the following reason:
> I have a function (for example called sub work()), that can be called in 2
> ways:
> 
> 1) work("text");
> 
> or
> 
> 2) work(12);
> 
> In case 1 i want to convert the given text to a list of decimal numbers
> representing the asc values (via ord()).
> In case 2 i want to work direcly with the number.
> 
> How can i destinguish in the function if a text or a number has been
> specified to the function?


sub work {

        my $arg = shift;

if ($arg =~ /^\d+$/) {
        # arg is a pure number
} else {
        # arg is not a pure number
}

}


# or pass a second arg to tell it that it's a number:

sub work {
        my ($type, $arg) = @_;

if ($type == 1) {
...

}

-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to