why don't doing like this:

$s = "text";
$f = 1;
works($s, $f);
or

$n = 1234;
$f = 0;
works($n, $f);


sub works {
  $para = shift;
  $flag = shift;

  if ($flag == 1) {
    # string
  } else {
    # number
  }
}

---------------------
Friedel Wittrock


-----Original Message-----
From: Ulrich Holeschak [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 1:49 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Check data type?


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?

-----Urspr�ngliche Nachricht-----
Von: "Robert Thorpe" <[EMAIL PROTECTED]>
An: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Gesendet: Montag, 10. Juni 2002 12:54
Betreff: Re: Check data type?


> On 10 Jun 2002, at 11:59, [EMAIL PROTECTED] wrote:
>
> > Yes, see the perlnumber documentation:
> > Storing numbers
> > Perl can internally represent numbers in 3 different ways: as native
> > integers, as native floating point numbers, and as decimal strings.
Decimal
> > strings may have an exponential notation part, as in "12.34e-56". Native
> > here means ``a format supported by the C compiler which was used to
build
> > perl''.
> >
> > But i can find which of the 3 types i have?
>
> AFAIK this is not possible.  When does it matter for practical
> purposes though?  Is it a speed/space thing?
>
> The perlfaq server has an answer to this using regexp's it's hacky
> and produces flammage whenever it's posted on
> comp.lang.perl.misc.
>
> search groups.google.com for
> "FAQ: How do I determine whether a scalar is a number"
>
> It would be useful to have a way to know types, like in lisp by
> integerp, numberp etc.
>
> >
> > -----Urspr�ngliche Nachricht-----
> > Von: "parvez" <[EMAIL PROTECTED]>
> > An: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Gesendet: Montag, 10. Juni 2002 11:46
> > Betreff: Re: Check data type?
> >
> >
> > > Hi,
> > >     Does Perl have a datatype?
> > > Parvez
> > >
> > >
> > > [EMAIL PROTECTED] wrote:
> > >
> > > > Hello,
> > > > how can i find out the internal data representation (data type) of a
> > perl
> > > > variable?
> > > >
> > > > Example:
> > > > $Var1 = 1234;            # this is an integer
> > > > $Var2 = "1234";        # this is an string
> > > >
> > > > I want to know if $VarX is internally stored as integer or as
string.
> > > >
> > > > Ulrich Holeschak
> > > > Bihl+Wiedemann GmbH
> > > > Flosswoerthstrasse 41
> > > > D-68199 Mannheim
> > > > Tel. +49 621/ 33996-0
> > > > Fax. +49 621/ 3392239
> > > > eMail: [EMAIL PROTECTED]
> > > > http://www.bihl-wiedemann.de
> > > >
> > > > _______________________________________________
> > > > ActivePerl mailing list
> > > > [EMAIL PROTECTED]
> > > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> > >
> >
> > _______________________________________________
> > ActivePerl mailing list
> > [EMAIL PROTECTED]
> > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
>
>
>
>
> --
> The information in this e-mail is for use by the addressee(s) only. If you
> are not the intended recipient, please notify us immediately and delete
the
> message from your computer. No liability or responsibility is accepted for
> viruses and it is your responsibility to scan attachments (if any).
> Opinions and views expressed in this email are those of the sender and
> do not reflect the opinions and views of antenova Ltd.
>

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

Reply via email to