in reply to Re: reading from middle of file
in thread reading from middle of file

Thank you, it has worked!! I only have two more questions.

Question 1:
First, if I'm printing a string and the value of a calculation of 2 variables, as in:

print "The average is $total/$count";
...how can I do it so that the value of the calculation shows up?? Right now I'm getting something like:
The average is 60/9
Do I have to use PRINTF??? In fact, while we're on this subject, how can I format the value so that it only has two decimal places?

Question 2:
What are these NEXT, UNLESS and LAST statements? In my whooping 1 week of PERL, I haven't yet come across these statements. I'd like to learn. Can you suggest a good place for looking up PERL syntax/statements?

Thanks a bunch

Replies are listed 'Best First'.
Re^3: reading from middle of file
by davorg (Chancellor) on Aug 12, 2004 at 16:50 UTC
    Question 1:
    First, if I'm printing a string and the value of a calculation of 2 variables, as in:
    print "The average is $total/$count";
    ...how can I do it so that the value of the calculation shows up?? Right now I'm getting something like:
    The average is 60/9

    Just take the calculation out of the quoted string.

    print "The average is ", $total/$count;
    Do I have to use PRINTF??? In fact, while we're on this subject, how can I format the value so that it only has two decimal places?

    That you can do with printf.

    printf "The average is %.2f", $total/$count;
    Question 2:
    What are these NEXT, UNLESS and LAST statements? In my whooping 1 week of PERL, I haven't yet come across these statements. I'd like to learn. Can you suggest a good place for looking up PERL syntax/statements?

    Type perldoc perltoc at your command line to see the table of contents for the Perl documentation. For the loop control statements, see the "Loop control" section in perldoc perlsyn.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re^3: reading from middle of file
by Random_Walk (Prior) on Aug 12, 2004 at 16:55 UTC
    print "The average is " . $total/$count . "\n";

    -or a little more fun-

    print "The average is @{[$total/$count]}\n";

    but as you say this is floating point output so printf it:

    printf ("The average is %2.2f",  $total/$count)

    Cheers,
    R.