52 users online (1 members and 51 guests)  

Thread: 3 questions


  Results 1 to 3 of 3

Related

  1. some php questions    Forum: PHP Forum
    Replies: 0
  2. How to do this in CSS? A few questions.    Forum: CSS Forum
    Replies: 0
  3. Six Questions    Forum: HTML Forum
    Replies: 4
  4. Some questions...    Forum: HTML Forum
    Replies: 10
  5. Questions...    Forum: HTML Forum
    Replies: 1
  1. #1
    r4874C's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2006
    Posts
    7

    3 questions

    1. how do I find number of elements in an array

    2. how do I find nearest integer greater value
    f.e. 1.6 after applying this function must be 2

    3. if ($f) { } - this means if $f exist run operators in { } . How will it look like to run operators in { } if $f don't exist.

    if ($f eq $d) { } - this means if $f =$d run operators in { } . How will it look like for $f> =$d, <=, <, >

  2. #2
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: 3 questions

    I don't code in PERL, but I've found the following info ...
    1. No idea, but this page might offer some clues.
    2. Most languages have an "INT" or function - but this tends to round down, so you can use
    Code:
    $i = INT($val + 0.5)
    Note that this will always round x.5 UP.
    3. a. Assuming that if ($f) means "if $f exists" then you could use
    Code:
    if ($f) { do stuff }
    else
    { do other stuff }
    3. b. http://compsoc.dur.ac.uk/workshops/intro2perl/node6.html
    Last edited by HTML; 03-09-2012 at 06:24 PM.

  3. #3
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Re: 3 questions

    Quote Originally Posted by r4874C
    3. if ($f) { } - this means if $f exist run operators in { } . How will it look like to run operators in { } if $f don't exist.

    if ($f eq $d) { } - this means if $f =$d run operators in { } . How will it look like for $f> =$d, <=, <, >
    Question 3 has two parts: does $f exist? how does $f relate to $d?
    If you are testing for the presence of $f then like DeadMeatGF said:
    Code:
    if ($f) { 
       do something;
    } else {
       do something_else;
    }
    Or you could do it backwards:
    Code:
    if (! $f) {
       do something;
    } else {
       do something_else;
    }
    For the second question:
    Code:
    if ($f == $d) {
       do equal;
    } elsif ($f < $d) {
       do less_than;
    } elsif ($f > $d) {
       do greater_than;
    } elsif ($f ...
    You'd probably also want to test for the existance of $f and $d before you begin:
    Code:
    if ($f && $d) {
       begin everything else here;
    }
    Here's a list and explanation of operators:
    http://www.cs.cmu.edu/People/rgs/pl-exp-op.html

    hth
    u
    Last edited by uthus; 05-07-2006 at 04:24 PM.



Tags for this Thread