Core iTOps Tube

Monday, 14 May 2012

Basic Question on perl use POSIX [SOLVED]

Hi guys,



I think this is a basic question. I'm not very familiar with this.



I'm trying to round a number up and round a number down. From what I have read this can be done using POSIX. I have tried to to use this, but i'm getting errors:




Code:




sub findGridBounds($$$%)

{

    use POSIX;

    my ($searchValue, $key, $gridTableKey, %gridTable) = @_;

   

    if (exists $gridTable{ $key })                               

    {

        my $inc = ($gridTable{$gridTableKey}[1] - $gridTable{$gridTableKey}[0]) / 501;

        my $mid = (($searchValue - $gridTable{$gridTableKey}[0]) / $inc) + 1;

       

       

        my $gridUpper = ceil($mid);

        my $gridLower = floor($mid);   

        print "Upper is: $gridUpper Lower is: $gridLower\n";



    }



}


I'm getting the following error:




Code:


Global symbol "$gridUpper" requires explicit package name

Global symbol "$gridLower" requires explicit package name


I'm not sure what i'm doing wrong. I'm thinking it has something to do with use POSIX, but i'm not sure.



Thanks guys!



---------- Post updated at 02:00 PM ---------- Previous update was at 12:10 PM ----------



Sorry for waiting ur time.... I just had a stupid syntax error... I'm just learning Perl. Please forgive me.




No comments:

Post a Comment