New to cig question

Discussion in 'Perl Misc' started by Ron, Jul 21, 2003.

  1. Ron

    Ron Guest

    Having problem with this code.
    First line works
    3rd line works
    2nd line I never get a greater than answer even when it's true.

    my $size_file = (-s $FILE1)/1024;
    if (($size_file > 0)) {
    my $YourFiles1 = 'File1: ' . $filename1 . ' ' . $size_file . ' KB';
    }

    Could anyone let me know what I am doing wrong?

    Thanks,
    Ron
     
    Ron, Jul 21, 2003
    #1
    1. Advertising

  2. Ron

    Ron Guest

    Hi Eric,

    I have printed out both
    my $size_file = (-s $FILE1)/1024;
    is value is 43

    I have printed out
    my $YourFiles1 = 'File1: ' . $filename1 . ' ' . $size_file . ' KB';
    'File1' is just a label
    $filename1 is a file name&extension

    Thanks,
    Ron



    "Eric Schwartz" <> wrote in message
    news:...
    > "Ron" <> writes:
    > > Having problem with this code.
    > > First line works
    > > 3rd line works
    > > 2nd line I never get a greater than answer even when it's true.
    > >
    > > my $size_file = (-s $FILE1)/1024;

    >
    > What is the contents of $FILE1 here? What is the value of $size_file
    > here?
    >
    > > if (($size_file > 0)) {

    >
    > Ditch the extra set of parentheses. And when you say the contents of
    > this if block don't execute even when it's true, how do you know it's
    > true? Because you've printed out $size_file, or because you know the
    > size of the file you think you're looking at?
    >
    > > my $YourFiles1 = 'File1: ' . $filename1 . ' ' . $size_file . ' KB';

    >
    > Hrm... above you use $FILE1; here you use $filename1. Which one
    > actually contains the name of the file you're looking at? I'd bet one
    > or possible both of these is wrong.
    >
    > -=Eric
    > --
    > Come to think of it, there are already a million monkeys on a million
    > typewriters, and Usenet is NOTHING like Shakespeare.
    > -- Blair Houghton.
     
    Ron, Jul 21, 2003
    #2
    1. Advertising

  3. Because it's hard to understand.

    Why don't people like top-posting?

    "Ron" <> writes:
    > I have printed out both
    > my $size_file = (-s $FILE1)/1024;
    > is value is 43


    If so, then the statment

    if($size_file > 0) {
    #do something
    }

    would execute. I promise you, Perl is not capricious-- if the
    variable is > 0 at that point, then the contents of the if() statement
    will execute. It seems to me that what we're seeing, and what your
    code actually looks like, is not the same thing.

    I would recommend you try to distill this particular problem to a very
    small program (10-15 lines should be plenty), and post that program
    here, along with what it outputs for you, and what it should output.

    Very often, the simple exercise of trying to reduce the trouble to its
    smallest essence is all that's required to find your problem.

    And again, please don't top-post; it's rude, and difficult to read.
    Intersperse your replies with the material you're replying to, as most
    other posters here do. Also, please trim the post you're quoting so
    that you're only replying to the most significant bits.

    http://www.html-faq.com/etiquette/?toppost

    -=Eric
    --
    Come to think of it, there are already a million monkeys on a million
    typewriters, and Usenet is NOTHING like Shakespeare.
    -- Blair Houghton.
     
    Eric Schwartz, Jul 21, 2003
    #3
  4. Alan J. Flavell, Jul 22, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robb Smith
    Replies:
    2
    Views:
    595
    Saravana
    Jul 18, 2003
  2. Dodo
    Replies:
    1
    Views:
    371
    Ron Natalie
    Aug 26, 2003
  3. George2
    Replies:
    1
    Views:
    350
    James Kanze
    Jan 29, 2008
  4. Sue
    Replies:
    8
    Views:
    149
    Thomas 'PointedEars' Lahn
    Dec 13, 2003
  5. Replies:
    2
    Views:
    502
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page