On Nov 18, 2007 7:32 PM, Thomas F. Droege <[EMAIL PROTECTED]> wrote:
> Trying to use floor:
snip

The ceil and floor functions are defined in the POSIX module.  Read
"perldoc -q floor" for more info.

#!/usr/bin/perl

use strict;
use warnings; #don't use -w if you are going to use the warnings
pragma, it is redundant
use POSIX;

#use line terminators, otherwise you might not see the prompt due to buffering
print "enter a number to be floored\n";
#define variables as late as possible and avoid initializing them with data
#you plan to through away (undef values are very useful in debugging)
my $foo = <>;
my $goo = floor($foo);
print "floor is $goo\n";

snip
0) My first post here - please correct me if I am not using correctly
I am an engineer not a professional programmer so please don't tell
me you do it just like in c. (an answer I often see in the doc)
snip

Seems fine to me.

snip
1) I suspect a version problem since search indicates floor added after
5.0
How do I ask perl what version is installed?
snip

Not an version problem, they just aren't exported by default (you need
to use the POSIX module), but you can get the version of Perl by
saying

perl -v

The current version is 5.8.8 with 5.10 coming out real soon (5.9, like
all odd middle digit version numbers in Perl, is a development
version).

snip
2) I am running Mandriva 2006 on an Intel 64 bit dual, dual (very nice).
Running somewhat older version of Mandriva because I know it's bugs.
snip

You most likely have a version of 5.8 installed.

snip
3) How would I download later version of perl if that is needed?
snip

In general you should use the package system your OS provides (in
Mandriva's case this is RPM/YUM).  If you absolutely had to have the
latest and greatest version of Perl you could download the source for
perl.org and compile it (it is not very difficult), but using the
package system is preferable.

snip
4) Looking at CPAN I see that math.ops has what I need.  How do I add
math.ops to my program?  I am a real beginner so I would need details.
snip

I doubt you found a module named math.ops (I don't think it is a valid
module name).  A quick search on CPAN shows that math.ops is part of
Parrot (an experimental virtual machine associated with the equally
highly experimental Perl 6) not Perl.  If you had found a module that
you needed to install (not part of Core Perl like POSIX), you would
have had three options (in order of preference):

1. install through your package manager:

yum install foo-bar.rpm

foo-bar often fits a pattern.  Ubuntu's pattern is given Foo::Bar the
package name will be libfoo-bar-perl.deb.  Mandriva's seems to be
something like perl-Foo-Bar-versioninfo.rpm.

2. install using CPAN

If you have a recent enough version of Perl you can say:

cpan install Foo::Bar

otherwise you will have to do it the old school way:

perl -MCPAN install Foo::Bar

3. install it manually

download the tar ball from cpan.org
decompress it
change directory into the resulting directory
type "perl Makefile.PL"
type "make"
type "make test"
ensure that none of the tests failed
type "sudo make install"

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to