in reply to Re: perl typecasting
in thread perl typecasting

Thanks guys..!! This helps..!!!

But I dont have 'strict' and 'warnings' at my workplace. I tried using it and it says that the module could not be found. This is turning out to be quite a problem...!!

But, i think I can use the \d matching given above. This should enable me to confirm if all characters are valid numbers.

Again.. Thanks for your help.. And sorry I didnt post code. I was not aware of the norms of the forums here and also the code slice was kinda large....!!!

Replies are listed 'Best First'.
Re^3: perl typecasting
by swampyankee (Parson) on Feb 04, 2008 at 23:29 UTC

    Not having strict and warnings seems quite odd, as I believe they're part of core Perl. As for the code you've been requested to post, it would be the code that is being used to perform the validations, which I would expect to be fairly short: a single regexp to validate integers (untested: $integer =~ /^ *[+-]?[0-9]+$/;, i.e., any number of blanks, an optional sign, and at least one digit before the end-of-string) and a more complex regexp to validate floats (in my other language, I'd just try to read a string as float or as an integer and handle the cases where there's a non-zero error code returned).


    emc

    Information about American English usage here and here.

    Floating point issues? Read this before posting: http://docs.sun.com/source/806-3568/ncg_goldberg.html

Re^3: perl typecasting
by TGI (Parson) on Feb 05, 2008 at 01:26 UTC

    The pragmata strict and warnings are part of the core distribution and have been for many years. Your perl installation may be damaged or your PERL5LIB environment variable may be wrong. Check the output from perl -V.

    In particular, note the version of perl and the values of PERL5LIB and @INC.


    TGI says moo

Re^3: perl typecasting
by Anonymous Monk on Feb 05, 2008 at 00:25 UTC
    You can turn on warnings, at least, from the command line when you invoke perl, e.g.,

    perl -w dubious_script.pl

    You can also turn on warnings from within a script with the statement

    BEGIN { $^W = 1; }

    Without access to the strict module, you will have trouble using many, if not most, of the modules referred to by others. A very strange situation, as has been mentioned; are you sure it's not available?

      Anonymous monk,

      If I use the strict module, it throws an error saying that the used module cannot be found. Is there anyway I can confirm this? check some path may be..... I experience the same errors on using the date and the time modules. The only one that works is the Fcntl module. Please let me know your thoughts.

      Thanks..!!!